Skip to content

Commit b387268

Browse files
committed
chore: update org page pipes to use slug instead of id
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
1 parent 5c0e982 commit b387268

7 files changed

Lines changed: 49 additions & 17 deletions

services/libs/tinybird/pipes/org_page_activities_timeseries.pipe

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ DESCRIPTION >
33

44
TAGS "Organization page"
55

6-
NODE org_page_activities_timeseries_data
6+
NODE org_slug_lookup
77
SQL >
88
%
9+
SELECT id FROM organizations_populated_slug
10+
WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }}
11+
12+
NODE org_page_activities_timeseries_data
13+
SQL >
914
SELECT startDate, endDate, activityCount
1015
FROM org_page_activities_timeseries_copy_ds FINAL
11-
WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
16+
WHERE organizationId = (SELECT id FROM org_slug_lookup)
1217
ORDER BY startDate

services/libs/tinybird/pipes/org_page_contributors.pipe

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ DESCRIPTION >
44

55
TAGS "Organization page"
66

7+
NODE org_slug_lookup
8+
SQL >
9+
%
10+
SELECT id FROM organizations_populated_slug
11+
WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }}
12+
713
NODE org_page_contributors_activity_aggregates
814
SQL >
915
%
1016
{% if Boolean(count, false) %}
1117
SELECT count(distinct memberId)
1218
FROM activityRelations_deduplicated_cleaned_bucket_union
1319
WHERE
14-
organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
20+
organizationId = (SELECT id FROM org_slug_lookup)
1521
{% if defined(startDate) %}
1622
AND timestamp
1723
>= {{ DateTime(startDate, description="Filter activity timestamp after") }}
@@ -26,7 +32,7 @@ SQL >
2632
ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (), 2) as "contributionPercentage"
2733
FROM activityRelations_deduplicated_cleaned_bucket_union
2834
WHERE
29-
organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
35+
organizationId = (SELECT id FROM org_slug_lookup)
3036
{% if defined(startDate) %}
3137
AND timestamp
3238
>= {{ DateTime(startDate, description="Filter activity timestamp after") }}
@@ -47,7 +53,7 @@ SQL >
4753
SELECT count(distinct memberId) as count
4854
FROM activityRelations_deduplicated_cleaned_bucket_union
4955
WHERE
50-
organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
56+
organizationId = (SELECT id FROM org_slug_lookup)
5157
{% if defined(startDate) %} AND timestamp >= {{ DateTime(startDate) }} {% end %}
5258
{% if defined(endDate) %} AND timestamp < {{ DateTime(endDate) }} {% end %}
5359
{% else %}

services/libs/tinybird/pipes/org_page_contributors_timeseries.pipe

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ DESCRIPTION >
33

44
TAGS "Organization page"
55

6-
NODE org_page_contributors_timeseries_data
6+
NODE org_slug_lookup
77
SQL >
88
%
9+
SELECT id FROM organizations_populated_slug
10+
WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }}
11+
12+
NODE org_page_contributors_timeseries_data
13+
SQL >
914
SELECT startDate, endDate, contributorCount
1015
FROM org_page_contributors_timeseries_copy_ds FINAL
11-
WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
16+
WHERE organizationId = (SELECT id FROM org_slug_lookup)
1217
ORDER BY startDate

services/libs/tinybird/pipes/org_page_kpis.pipe

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ DESCRIPTION >
44

55
TAGS "Organization page"
66

7-
NODE org_page_kpis_main
7+
NODE org_slug_lookup
88
SQL >
99
%
10+
SELECT id FROM organizations_populated_slug
11+
WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }}
12+
13+
NODE org_page_kpis_main
14+
SQL >
1015
SELECT
1116
activeContributors,
1217
if(
@@ -25,4 +30,4 @@ SQL >
2530
maintainerRoles,
2631
criticalProjects
2732
FROM org_page_kpis_copy_ds FINAL
28-
WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
33+
WHERE organizationId = (SELECT id FROM org_slug_lookup)

services/libs/tinybird/pipes/org_page_profile.pipe

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@ DESCRIPTION >
44

55
TAGS "Organization page"
66

7-
NODE org_page_profile_base
7+
NODE org_slug_lookup
88
SQL >
99
%
10+
SELECT id FROM organizations_populated_slug
11+
WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }}
12+
13+
NODE org_page_profile_base
14+
SQL >
1015
SELECT id, displayName, logo, employees AS employeeCount, industry, headline AS description
1116
FROM organizations FINAL
12-
WHERE id = {{ String(orgId, '', description="Organization ID", required=True) }}
17+
WHERE id = (SELECT id FROM org_slug_lookup)
1318

1419
NODE org_page_profile_website
1520
SQL >
16-
%
1721
SELECT organizationId, argMax(value, updatedAt) AS website
1822
FROM organizationIdentities FINAL
1923
WHERE
20-
organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
24+
organizationId = (SELECT id FROM org_slug_lookup)
2125
AND type = 'primary-domain'
2226
GROUP BY organizationId
2327

services/libs/tinybird/pipes/org_page_projects.pipe

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ DESCRIPTION >
44

55
TAGS "Organization page"
66

7+
NODE org_slug_lookup
8+
SQL >
9+
%
10+
SELECT id FROM organizations_populated_slug
11+
WHERE slug = {{ String(orgSlug, '', description="Organization slug", required=True) }}
12+
713
NODE org_page_projects_main
814
SQL >
915
%
@@ -22,7 +28,7 @@ SQL >
2228
orgPrsOpened,
2329
technicalScore
2430
FROM org_page_projects_copy_ds FINAL
25-
WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
31+
WHERE organizationId = (SELECT id FROM org_slug_lookup)
2632
ORDER BY technicalScore DESC, activityCount DESC
2733
LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }}
2834
OFFSET {{ Int32(offset, 0, description="Pagination offset") }}

services/libs/tinybird/pipes/organizations_leaderboard.pipe

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DESCRIPTION >
1818
- `offset`: Optional integer for result pagination, defaults to 0
1919
- Response:
2020
- Count mode (`count=true`): `count` (total number of organizations)
21-
- Data mode (default): `id`, `logo`, `displayName`, `contributionCount`, `contributionPercentage`
21+
- Data mode (default): `id`, `slug`, `logo`, `displayName`, `contributionCount`, `contributionPercentage`
2222

2323
NODE organizations_leaderboard_paginated
2424
SQL >
@@ -28,13 +28,14 @@ SQL >
2828
{% else %}
2929
SELECT
3030
org.id AS id,
31+
org.slug AS slug,
3132
org.logo AS logo,
3233
org.displayName AS displayName,
3334
COUNT(af.id) AS contributionCount,
3435
ROUND(COUNT(af.id) * 100.0 / SUM(COUNT(af.id)) OVER (), 2) AS contributionPercentage
3536
FROM activities_filtered af
36-
JOIN organizations org FINAL ON org.id = af.organizationId
37-
GROUP BY org.id, org.logo, org.displayName
37+
JOIN organizations_populated_slug org ON org.id = af.organizationId
38+
GROUP BY org.id, org.slug, org.logo, org.displayName
3839
ORDER BY contributionCount DESC, id desc
3940
LIMIT {{ Int32(limit, 10) }}
4041
OFFSET {{ Int32(offset, 0) }}

0 commit comments

Comments
 (0)