Skip to content

Commit f00b9fd

Browse files
authored
feat: add github handle to member endpoints (IN-834) (#3742)
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent c104c36 commit f00b9fd

7 files changed

Lines changed: 49 additions & 29 deletions

services/libs/tinybird/datasources/leaderboards_copy_ds.datasource

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ DESCRIPTION >
1414
- `previousPeriodValue` is the comparison metric from the previous period (0 for non-temporal leaderboards).
1515
- `collectionsSlugs` list of collection slugs the project belongs to.
1616
- `isLF` indicates whether the project is a LF project (1 = true, 0 = false).
17+
- `githubHandle` is the GitHub username for contributor leaderboards (empty string for non-contributor leaderboards).
1718

1819
TAGS "Analytics, Leaderboards, Project rankings"
1920

@@ -28,7 +29,8 @@ SCHEMA >
2829
`value` Float64,
2930
`previousPeriodValue` Float64,
3031
`collectionsSlugs` Array(String),
31-
`isLF` UInt8
32+
`isLF` UInt8,
33+
`githubHandle` String
3234

3335
ENGINE MergeTree
3436
ENGINE_SORTING_KEY leaderboardType, rank, slug, id

services/libs/tinybird/datasources/members_sorted.datasource

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ DESCRIPTION >
1313
- `displayName` is the member's preferred display name across platforms.
1414
- `score` is the computed activity/engagement score for the member.
1515
- `publicName` is the denormalized public display name for efficient queries.
16+
- `githubHandle` is the member's GitHub username from memberIdentities (empty string if not available).
1617

1718
SCHEMA >
1819
`id` String,
@@ -29,7 +30,8 @@ SCHEMA >
2930
`updatedAt` DateTime64(3),
3031
`displayName` String,
3132
`score` Int32,
32-
`publicName` String
33+
`publicName` String,
34+
`githubHandle` String
3335

3436
ENGINE MergeTree
3537
ENGINE_PARTITION_KEY toYear(joinedAt)

services/libs/tinybird/pipes/contributor_dependency.pipe

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ DESCRIPTION >
1414
- `activity_type`: Optional string filter for single activity type (e.g., 'authored-commit')
1515
- `activity_types`: Optional array of activity types (e.g., ['authored-commit', 'co-authored-commit'])
1616
- `onlyContributions`: Optional boolean, defaults to 1 (contributions only), set to 0 for all activities
17-
- Response: `id`, `displayName`, `contributionCount`, `contributionPercentage`, `roles`, `contributionPercentageRunningTotal`, `totalContributorCount`
17+
- Response: `id`, `displayName`, `githubHandle`, `contributionCount`, `contributionPercentage`, `roles`, `contributionPercentageRunningTotal`, `totalContributorCount`
1818

1919
NODE contributions_percentage_running_total
2020
SQL >
@@ -24,6 +24,7 @@ SQL >
2424
SELECT
2525
id,
2626
displayName,
27+
githubHandle,
2728
contributionCount,
2829
contributionPercentage,
2930
roles,

services/libs/tinybird/pipes/contributors_leaderboard.pipe

Lines changed: 2 additions & 1 deletion
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 contributors)
21-
- Data mode (default): `id`, `avatar`, `displayName`, `contributionCount`, `contributionPercentage`, `roles`
21+
- Data mode (default): `id`, `avatar`, `displayName`, `githubHandle`, `contributionCount`, `contributionPercentage`, `roles`
2222

2323
NODE memberId_aggregates
2424
SQL >
@@ -55,6 +55,7 @@ SQL >
5555
m.id,
5656
m.avatar,
5757
case when is_non_lf.result then m.publicName else m.displayName end as displayName,
58+
m.githubHandle,
5859
ma.contributionCount,
5960
ma.contributionPercentage,
6061
mr.roles

services/libs/tinybird/pipes/leaderboards_copy.pipe

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
11
DESCRIPTION >
22
Aggregates all individual leaderboard pipes into a single unified datasource for querying.
3-
Consolidates 13 different leaderboard types with their respective rankings and values,
3+
Consolidates 10 different leaderboard types with their respective rankings and values,
44
and copies the results to a datasource on a daily schedule at 1 AM.
55

66
NODE leaderboards_copy_union
77
DESCRIPTION >
88
Unions all leaderboard results with their respective type identifiers for consolidated querying
99

1010
SQL >
11-
SELECT *, 'active-contributors' as leaderboardType
11+
SELECT *, '' as githubHandle, 'active-contributors' as leaderboardType
1212
FROM leaderboards_project_active_contributors
1313
UNION ALL
14-
SELECT *, 'active-organizations' as leaderboardType
14+
SELECT *, '' as githubHandle, 'active-organizations' as leaderboardType
1515
FROM leaderboards_project_active_organizations
1616
UNION ALL
17-
SELECT *, 'commit-activity' as leaderboardType
17+
SELECT *, '' as githubHandle, 'commit-activity' as leaderboardType
1818
FROM leaderboards_commits
1919
UNION ALL
20-
SELECT *, 'stars' as leaderboardType
20+
SELECT *, '' as githubHandle, 'stars' as leaderboardType
2121
FROM leaderboards_stars
2222
UNION ALL
23-
SELECT *, 'forks' as leaderboardType
23+
SELECT *, '' as githubHandle, 'forks' as leaderboardType
2424
FROM leaderboards_forks
2525
UNION ALL
26-
SELECT *, 'package-downloads' as leaderboardType
26+
SELECT *, '' as githubHandle, 'package-downloads' as leaderboardType
2727
FROM leaderboards_package_downloads
2828
UNION ALL
29-
SELECT *, 0.0 as previousPeriodValue, 'focused-teams' as leaderboardType
29+
SELECT *, 0.0 as previousPeriodValue, '' as githubHandle, 'focused-teams' as leaderboardType
3030
FROM leaderboards_avg_commits_per_author
3131
UNION ALL
32-
SELECT *, 0.0 as previousPeriodValue, 'small-teams-massive-output' as leaderboardType
32+
SELECT
33+
*,
34+
0.0 as previousPeriodValue,
35+
'' as githubHandle,
36+
'small-teams-massive-output' as leaderboardType
3337
FROM leaderboards_small_project_commit
3438
UNION ALL
35-
SELECT *, 0.0 as previousPeriodValue, 'codebase-size' as leaderboardType
39+
SELECT *, 0.0 as previousPeriodValue, '' as githubHandle, 'codebase-size' as leaderboardType
3640
FROM leaderboards_codebase_size
3741
UNION ALL
38-
SELECT *, 'fastest-mergers' as leaderboardType
42+
SELECT *, '' as githubHandle, 'fastest-mergers' as leaderboardType
3943
FROM leaderboards_merge_time
4044
UNION ALL
41-
SELECT *, 'fastest-responders' as leaderboardType
45+
SELECT *, '' as githubHandle, 'fastest-responders' as leaderboardType
4246
FROM leaderboards_issue_response
4347
UNION ALL
44-
SELECT *, 0.0 as previousPeriodValue, 'resolution-rate' as leaderboardType
48+
SELECT *, 0.0 as previousPeriodValue, '' as githubHandle, 'resolution-rate' as leaderboardType
4549
FROM leaderboards_resolution_rate
4650
UNION ALL
4751
SELECT *, 'contributors' as leaderboardType
4852
FROM leaderboards_members
4953
UNION ALL
50-
SELECT *, 'organizations' as leaderboardType
54+
SELECT *, '' as githubHandle, 'organizations' as leaderboardType
5155
FROM leaderboards_organizations
5256

5357
TYPE COPY

services/libs/tinybird/pipes/leaderboards_members.pipe

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DESCRIPTION >
88
Retrieves all members from the populated datasource
99

1010
SQL >
11-
SELECT id, displayName, avatar FROM members_sorted
11+
SELECT id, displayName, avatar, githubHandle FROM members_sorted
1212

1313
NODE leaderboards_member_activity_types
1414
DESCRIPTION >
@@ -66,13 +66,15 @@ SQL >
6666
arrayDistinct(arrayFlatten(groupArray(proj.collectionsSlugs))) as collectionSlugs,
6767
0 as isLF,
6868
cast(coalesce(c.memberActivityCount, 0) as Float64) as value,
69-
cast(coalesce(pp.memberActivityCount, 0) as Float64) as previousPeriodValue
69+
cast(coalesce(pp.memberActivityCount, 0) as Float64) as previousPeriodValue,
70+
p.githubHandle as githubHandle
7071
FROM leaderboards_members_data p
7172
INNER JOIN leaderboards_members_current_period c ON p.id = c.memberId
7273
LEFT JOIN leaderboards_members_previous_period pp ON p.id = pp.memberId ARRAY
7374
JOIN c.segmentIds as sid
7475
LEFT JOIN leaderboards_members_projects proj ON proj.segmentId = sid
7576
WHERE c.memberActivityCount > 0
76-
GROUP BY p.id, p.displayName, p.avatar, c.memberActivityCount, pp.memberActivityCount
77+
GROUP BY
78+
p.id, p.displayName, p.avatar, p.githubHandle, c.memberActivityCount, pp.memberActivityCount
7779
ORDER BY value DESC
7880
LIMIT 100

services/libs/tinybird/pipes/members_sorted_copy_pipe.pipe

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
DESCRIPTION >
22
Filters out `isBot = true` and `isTeamMember=true` members. Also possible to use more granular sorting keys in the destination datasource `members_sorted` Copy pipe runs every hour
33

4+
NODE github_usernames
5+
SQL >
6+
SELECT memberId, argMax(value, createdAt) AS githubHandle
7+
FROM memberIdentities FINAL
8+
WHERE platform = 'github' AND type = 'username'
9+
GROUP BY memberId
10+
411
NODE members_pre_filter
512
SQL >
6-
SELECT members.*, pub.publicName
7-
FROM members final
8-
left join members_public_names_ds pub on pub.memberId = members.id
9-
where
10-
not isBot
11-
and not isTeamMember
12-
and not isOrganization
13-
and members.id in (select distinct memberId from activityRelations)
13+
SELECT members.*, pub.publicName, coalesce(gh.githubHandle, '') AS githubHandle
14+
FROM members FINAL
15+
LEFT JOIN members_public_names_ds pub ON pub.memberId = members.id
16+
LEFT JOIN github_usernames gh ON gh.memberId = members.id
17+
WHERE
18+
NOT isBot
19+
AND NOT isTeamMember
20+
AND NOT isOrganization
21+
AND members.id IN (SELECT DISTINCT memberId FROM activityRelations)
1422

1523
TYPE COPY
1624
TARGET_DATASOURCE members_sorted

0 commit comments

Comments
 (0)