Skip to content

Commit 55180d5

Browse files
committed
feat: add a new Tinybird pipe to serve activity types by project
Signed-off-by: Raúl Santos <4837+borfast@users.noreply.github.com>
1 parent 8443c16 commit 55180d5

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
DESCRIPTION >
2+
- `activityTypes_by_project.pipe` returns activity types that actually exist for a given project.
3+
- Unlike `activityTypes_filtered` which returns all possible activity types, this pipe only returns types with actual activities in the project.
4+
- Useful for populating dropdowns, filters, or analytics that should only show activity types with data.
5+
- Parameters:
6+
- `project`: **Required** string for project slug (e.g., 'k8s', 'tensorflow'). Passed to `segments_filtered`.
7+
- `repos`: Optional array of repository URLs for filtering (e.g., ['https://github.com/kubernetes/kubernetes']). Filters activities by repository.
8+
- `includeCodeContributions`: Optional boolean to include code contribution activities. Defaults to 1. Set to 0 to exclude. Passed to `activityTypes_filtered`.
9+
- `includeCollaborations`: Optional boolean to include or exclude collaboration activities. Defaults to 0. Passed to `activityTypes_filtered`.
10+
- `includeOtherContributions`: Optional boolean to include other contribution activities (activities that are neither code contributions nor collaborations). Defaults to 0. Passed to `activityTypes_filtered`.
11+
- Response: `activityType`, `platform`, `label`.
12+
- This pipe ensures that only activity types with actual data are returned, avoiding empty states in UI.
13+
14+
NODE activityTypes_by_project_0
15+
SQL >
16+
%
17+
SELECT DISTINCT a.type as activityType, a.platform, at.label
18+
FROM activityRelations_deduplicated_cleaned_ds a
19+
INNER JOIN activityTypes at ON a.type = at.activityType AND a.platform = at.platform
20+
WHERE
21+
a.segmentId = (SELECT segmentId FROM segments_filtered)
22+
{% if defined(repos) %}
23+
AND a.channel
24+
IN {{ Array(repos, 'String', description="Filter activity repo list", required=False) }}
25+
{% end %}
26+
AND (a.type, a.platform) IN (SELECT activityType, platform FROM activityTypes_filtered)
27+
ORDER BY activityType, platform

0 commit comments

Comments
 (0)