You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: scope widget pipes by collection for Collections widget tabs
Adds segments_filtered_by_collection.pipe, the collection-scoped
counterpart to segments_filtered.pipe: resolves a collectionSlug to
every member project's insightsProjectId/segmentId/repositories via
insights_projects_populated_ds.collectionsSlugs, instead of a single
project's segment.
Updates the 7 leaf pipes that widgets in the Contributors, Popularity,
and Development tabs depend on to accept either project or
collectionSlug, switching their scalar '= (SELECT ... FROM
segments_filtered)' subquery to 'IN (SELECT ... FROM
segments_filtered_by_collection)' when scoped by collection:
activities_filtered, activities_filtered_retention,
activity_heatmap_by_weekday_and_2hours_blocks, pull_requests_filtered,
active_contributors (its own maintainers_count node), package_metrics,
packages, search_volume.
Every other widget pipe (leaderboards, dependency, retention,
geo-distribution, median times, review efficiency, merge lead time)
inherits collection scoping transparently through these 7, since they
already read from activities_filtered/pull_requests_filtered rather
than segments_filtered directly. segments_filtered itself and its
~25 other dependents (health scores, vulnerabilities, etc.) are left
untouched.
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copy file name to clipboardExpand all lines: services/libs/tinybird/pipes/activities_filtered.pipe
+9-3Lines changed: 9 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,12 @@ DESCRIPTION >
2
2
- `activities_filtered.pipe` is the core filtering infrastructure pipe for activity data across the entire analytics platform.
3
3
- This pipe serves as the foundation for most activity-related widgets, by providing a consistent, filtered view of contribution activities.
4
4
- It filters activities from `activityRelations_deduplicated_cleaned_ds` datasource based on project segment, time ranges, repositories, platforms, and activity types.
5
-
- The pipe automatically scopes data to the current project using `segments_filtered` pipe for security and data isolation.
5
+
- The pipe scopes data either to a single project (via `segments_filtered`) or to every project in a collection
6
+
(via `segments_filtered_by_collection`), for security and data isolation. Exactly one of `project`/`collectionSlug`
7
+
must be provided by the caller.
6
8
- Parameters:
7
-
- `project`: Inherited from `segments_filtered`, project slug (e.g., 'k8s', 'tensorflow')
9
+
- `project`: Project slug (e.g., 'k8s', 'tensorflow') - inherited from `segments_filtered`. Required unless `collectionSlug` is given.
10
+
- `collectionSlug`: Collection slug (e.g., 'cncf') - inherited from `segments_filtered_by_collection`. Required unless `project` is given.
8
11
- `repos`: Optional array of repository URLs for filtering (e.g., ['https://github.com/kubernetes/kubernetes']). Inherited from `segments_filtered`.
9
12
- `startDate`: Optional DateTime filter for activities after timestamp (e.g., '2024-01-01 00:00:00')
10
13
- `endDate`: Optional DateTime filter for activities before timestamp (e.g., '2024-12-31 23:59:59')
@@ -23,7 +26,10 @@ SQL >
23
26
SELECT activityId as id, timestamp, type, platform, memberId, organizationId, segmentId
24
27
FROM activityRelations_bucket_routing a
25
28
where
26
-
segmentId = (SELECT segmentId FROM segments_filtered)
29
+
{% if defined(collectionSlug) %}
30
+
segmentId IN (SELECT segmentId FROM segments_filtered_by_collection)
31
+
{% else %} segmentId = (SELECT segmentId FROM segments_filtered)
Copy file name to clipboardExpand all lines: services/libs/tinybird/pipes/activities_filtered_retention.pipe
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,8 @@ DESCRIPTION >
5
5
- This time extension ensures retention rate calculations have the necessary baseline data from the preceding period for comparing distinct member activity for the first given period.
6
6
- Primary use case: providing data foundation for member retention analysis and cohort studies.
7
7
- Parameters:
8
-
- `project`: Inherited from `segments_filtered`, project slug (e.g., 'k8s', 'tensorflow')
8
+
- `project`: Inherited from `segments_filtered`, project slug (e.g., 'k8s', 'tensorflow'). Required unless `collectionSlug` is given.
9
+
- `collectionSlug`: Inherited from `segments_filtered_by_collection`, collection slug (e.g., 'cncf'). Required unless `project` is given.
9
10
- `repos`: Inherited from `segments_filtered`, array of repository URLs for filtering
10
11
- `startDate`: Optional DateTime filter, automatically extended backwards by one granularity period
11
12
- `endDate`: Optional DateTime filter for activities before timestamp (e.g., '2024-12-31 23:59:59')
@@ -24,7 +25,10 @@ SQL >
24
25
SELECT activityId as id, timestamp, type, platform, memberId, organizationId, segmentId
25
26
FROM activityRelations_bucket_routing a
26
27
where
27
-
segmentId = (SELECT segmentId FROM segments_filtered)
28
+
{% if defined(collectionSlug) %}
29
+
segmentId IN (SELECT segmentId FROM segments_filtered_by_collection)
30
+
{% else %} segmentId = (SELECT segmentId FROM segments_filtered)
31
+
{% end %}
28
32
{% if defined(startDate) %}
29
33
AND a.timestamp
30
34
> {% if defined(granularity) and granularity == "daily" %}
0 commit comments