diff --git a/scripts/cli b/scripts/cli index 117f1b371d..7bdfd7e3be 100755 --- a/scripts/cli +++ b/scripts/cli @@ -1182,14 +1182,14 @@ while test $# -gt 0; do exit ;; service-restart-fe-dev) - 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") + 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") DEV=1 kill_all_containers service_start exit ;; clean-start-fe-dev) - 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") + 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") CLEAN_START=1 DEV=1 start diff --git a/services/libs/tinybird/pipes/collection_insights_aggregate.pipe b/services/libs/tinybird/pipes/collection_insights_aggregate.pipe new file mode 100644 index 0000000000..15a5c1f2c6 --- /dev/null +++ b/services/libs/tinybird/pipes/collection_insights_aggregate.pipe @@ -0,0 +1,50 @@ +DESCRIPTION > + - `collection_insights_aggregate.pipe` serves aggregate insights metrics for a collection. + - Returns a single row with metrics aggregated across every project in the collection, not one row per project. + - Parameters: + - `collectionSlug`: Required collection slug. insights_projects_populated_ds.collectionsSlugs already lists + every collection each project belongs to (see insightsProjects_filtered.pipe for the same filter pattern), + so this pipe resolves collection membership directly rather than requiring the caller to first look up a + project id list. + - Response: + - `projectCount`: count of distinct projects in the collection. + - `uniqueContributorCount`: total unique contributors across all projects in the collection, deduplicated (a contributor active on multiple projects in the collection is counted once). + - `avgHealthScore`: average of each project's health score in the collection, rounded. + +TAGS "Insights, Widget", "Collection" + +NODE collection_insights_aggregate_projects +DESCRIPTION > + Resolves the collection's member projects to their segment ids and health scores directly via + collectionsSlugs, matching the same has(collectionsSlugs, ...) filter already used by + insightsProjects_filtered.pipe. + +SQL > + % + SELECT id, segmentId, healthScore + FROM insights_projects_populated_ds + WHERE + enabled = 1 + AND has( + collectionsSlugs, + {{ String(collectionSlug, description="Filter by collection slug", required=True) }} + ) + +NODE collection_insights_aggregate_results +DESCRIPTION > + Aggregates health score across matched projects and counts unique contributors across their segments in one pass + +SQL > + SELECT + (SELECT count(distinct id) FROM collection_insights_aggregate_projects) AS projectCount, + uniq(ar.memberId) AS uniqueContributorCount, + (SELECT round(avg(healthScore)) FROM collection_insights_aggregate_projects) AS avgHealthScore + FROM activityRelations_deduplicated_cleaned_bucket_union AS ar + WHERE + ar.memberId != '' + AND ar.segmentId IN (SELECT segmentId FROM collection_insights_aggregate_projects) + AND (ar.type, ar.platform) IN ( + SELECT activityType, platform + FROM activityTypes + WHERE isCodeContribution = 1 OR isCollaboration = 1 + )