Skip to content

Commit 7a486b3

Browse files
authored
feat: collections v2 aggregate Tinybird pipes and toggle column (IN-1193) (#4336)
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent d320aa8 commit 7a486b3

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

scripts/cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,14 +1182,14 @@ while test $# -gt 0; do
11821182
exit
11831183
;;
11841184
service-restart-fe-dev)
1185-
IGNORED_SERVICES=("frontend" "python-worker" "job-generator" "webhook-api" "profiles-worker" "organizations-enrichment-worker" "merge-suggestions-worker" "members-enrichment-worker" "exports-worker" "entity-merging-worker")
1185+
IGNORED_SERVICES=("frontend" "python-worker" "job-generator" "webhook-api" "profiles-worker" "organizations-enrichment-worker" "merge-suggestions-worker" "members-enrichment-worker" "exports-worker" "entity-merging-worker" "automatic-projects-discovery-worker" "pcc-sync-worker" "projects-evaluation-worker" "bq-dataset-ingest" "cargo-worker" "dockerhub-sync" "github-repos-enricher" "go-worker" "maven-worker" "npm-worker" "nuget-worker" "osv-worker" "pypi-worker" "rubygems-worker" "security-contacts-worker")
11861186
DEV=1
11871187
kill_all_containers
11881188
service_start
11891189
exit
11901190
;;
11911191
clean-start-fe-dev)
1192-
IGNORED_SERVICES=("frontend" "python-worker" "job-generator" "webhook-api" "profiles-worker" "organizations-enrichment-worker" "merge-suggestions-worker" "members-enrichment-worker" "exports-worker" "entity-merging-worker" "cache-worker" "categorization-worker" "cron-service" "data-sink-worker" "git-integration" "integration-run-worker" "integration-stream-worker" "nango-webhook-api" "nango-worker" "script-executor-worker" "search-sync-api" "search-sync-worker" "security-best-practices-worker" "snowflake-connectors-worker")
1192+
IGNORED_SERVICES=("frontend" "python-worker" "job-generator" "webhook-api" "profiles-worker" "organizations-enrichment-worker" "merge-suggestions-worker" "members-enrichment-worker" "exports-worker" "entity-merging-worker" "cache-worker" "categorization-worker" "cron-service" "data-sink-worker" "git-integration" "integration-run-worker" "integration-stream-worker" "nango-webhook-api" "nango-worker" "script-executor-worker" "search-sync-api" "search-sync-worker" "security-best-practices-worker" "snowflake-connectors-worker" "automatic-projects-discovery-worker" "pcc-sync-worker" "projects-evaluation-worker" "bq-dataset-ingest" "cargo-worker" "dockerhub-sync" "github-repos-enricher" "go-worker" "maven-worker" "npm-worker" "nuget-worker" "osv-worker" "pypi-worker" "rubygems-worker" "security-contacts-worker")
11931193
CLEAN_START=1
11941194
DEV=1
11951195
start
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
DESCRIPTION >
2+
- `collection_insights_aggregate.pipe` serves aggregate insights metrics for a collection.
3+
- Returns a single row with metrics aggregated across every project in the collection, not one row per project.
4+
- Parameters:
5+
- `collectionSlug`: Required collection slug. insights_projects_populated_ds.collectionsSlugs already lists
6+
every collection each project belongs to (see insightsProjects_filtered.pipe for the same filter pattern),
7+
so this pipe resolves collection membership directly rather than requiring the caller to first look up a
8+
project id list.
9+
- Response:
10+
- `projectCount`: count of distinct projects in the collection.
11+
- `uniqueContributorCount`: total unique contributors across all projects in the collection, deduplicated (a contributor active on multiple projects in the collection is counted once).
12+
- `avgHealthScore`: average of each project's health score in the collection, rounded.
13+
14+
TAGS "Insights, Widget", "Collection"
15+
16+
NODE collection_insights_aggregate_projects
17+
DESCRIPTION >
18+
Resolves the collection's member projects to their segment ids and health scores directly via
19+
collectionsSlugs, matching the same has(collectionsSlugs, ...) filter already used by
20+
insightsProjects_filtered.pipe.
21+
22+
SQL >
23+
%
24+
SELECT id, segmentId, healthScore
25+
FROM insights_projects_populated_ds
26+
WHERE
27+
enabled = 1
28+
AND has(
29+
collectionsSlugs,
30+
{{ String(collectionSlug, description="Filter by collection slug", required=True) }}
31+
)
32+
33+
NODE collection_insights_aggregate_results
34+
DESCRIPTION >
35+
Aggregates health score across matched projects and counts unique contributors across their segments in one pass
36+
37+
SQL >
38+
SELECT
39+
(SELECT count(distinct id) FROM collection_insights_aggregate_projects) AS projectCount,
40+
uniq(ar.memberId) AS uniqueContributorCount,
41+
(SELECT round(avg(healthScore)) FROM collection_insights_aggregate_projects) AS avgHealthScore
42+
FROM activityRelations_deduplicated_cleaned_bucket_union AS ar
43+
WHERE
44+
ar.memberId != ''
45+
AND ar.segmentId IN (SELECT segmentId FROM collection_insights_aggregate_projects)
46+
AND (ar.type, ar.platform) IN (
47+
SELECT activityType, platform
48+
FROM activityTypes
49+
WHERE isCodeContribution = 1 OR isCollaboration = 1
50+
)

0 commit comments

Comments
 (0)