|
| 1 | +DESCRIPTION > |
| 2 | + Leaderboard ranking organizations by total number of contribution activities. Counts all |
| 3 | + contribution activities (collaboration or code contributions) per organization. Compares the |
| 4 | + current period (last 12 months) with the previous period (12-24 months ago). |
| 5 | + |
| 6 | +NODE leaderboards_organizations_data |
| 7 | +DESCRIPTION > |
| 8 | + Retrieves all organizations from the populated datasource |
| 9 | + |
| 10 | +SQL > |
| 11 | + SELECT id, displayName, logo FROM organizations FINAL |
| 12 | + |
| 13 | +NODE leaderboards_organizations_activity_types |
| 14 | +DESCRIPTION > |
| 15 | + Filters activity types to include only collaboration and code contribution activities |
| 16 | + |
| 17 | +SQL > |
| 18 | + SELECT activityType, platform FROM activityTypes FINAL WHERE isCollaboration or isCodeContribution |
| 19 | + |
| 20 | +NODE leaderboards_organizations_current_period |
| 21 | +DESCRIPTION > |
| 22 | + Counts total contribution activities per organization for the last 12 months |
| 23 | + |
| 24 | +SQL > |
| 25 | + SELECT organizationId, count(*) AS organizationActivityCount |
| 26 | + FROM activityRelations_deduplicated_cleaned_ds ar |
| 27 | + INNER JOIN |
| 28 | + leaderboards_organizations_activity_types at |
| 29 | + ON ar.type = at.activityType |
| 30 | + AND ar.platform = at.platform |
| 31 | + WHERE organizationId != '' AND timestamp >= now() - INTERVAL 12 MONTH AND timestamp < now() |
| 32 | + GROUP BY organizationId |
| 33 | + |
| 34 | +NODE leaderboards_organizations_previous_period |
| 35 | +DESCRIPTION > |
| 36 | + Counts total contribution activities per organization for the previous 12 months (12-24 months ago) |
| 37 | + |
| 38 | +SQL > |
| 39 | + SELECT organizationId, count(*) AS organizationActivityCount |
| 40 | + FROM activityRelations_deduplicated_cleaned_ds ar |
| 41 | + INNER JOIN |
| 42 | + leaderboards_organizations_activity_types at |
| 43 | + ON ar.type = at.activityType |
| 44 | + AND ar.platform = at.platform |
| 45 | + WHERE |
| 46 | + organizationId != '' |
| 47 | + AND timestamp >= now() - INTERVAL 24 MONTH |
| 48 | + AND timestamp < now() - INTERVAL 12 MONTH |
| 49 | + GROUP BY organizationId |
| 50 | + |
| 51 | +NODE leaderboards_organizations_results |
| 52 | +DESCRIPTION > |
| 53 | + Joins organization metadata with current and previous period activity counts, ranks by most activities |
| 54 | + |
| 55 | +SQL > |
| 56 | + SELECT |
| 57 | + row_number() OVER (ORDER BY coalesce(c.organizationActivityCount, 0) DESC) as rank, |
| 58 | + p.id as id, |
| 59 | + '' as segmentId, |
| 60 | + p.displayName as name, |
| 61 | + '' as slug, |
| 62 | + p.logo as logoUrl, |
| 63 | + cast(coalesce(c.organizationActivityCount, 0) as Float64) as value, |
| 64 | + cast(coalesce(pp.organizationActivityCount, 0) as Float64) as previousPeriodValue |
| 65 | + FROM leaderboards_organizations_data p |
| 66 | + INNER JOIN leaderboards_organizations_current_period c ON p.id = c.organizationId |
| 67 | + LEFT JOIN leaderboards_organizations_previous_period pp ON p.id = pp.organizationId |
| 68 | + WHERE c.organizationActivityCount > 0 |
| 69 | + ORDER BY value DESC |
0 commit comments