Skip to content

Commit 85aed81

Browse files
committed
feat: add technical score to org page projects copy pipe
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent 283716f commit 85aed81

3 files changed

Lines changed: 78 additions & 3 deletions

File tree

services/libs/tinybird/datasources/org_page_projects_copy_ds.datasource

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ SCHEMA >
1010
`projectLogo` String,
1111
`activityCount` UInt64,
1212
`contributorCount` UInt64,
13+
`maintainersCount` UInt64,
14+
`totalContributors` UInt64,
15+
`orgContributors` UInt64,
16+
`totalCommits` UInt64,
17+
`orgCommits` UInt64,
18+
`totalPrsOpened` UInt64,
19+
`orgPrsOpened` UInt64,
20+
`technicalScore` UInt64,
1321
`computedAt` DateTime
1422

1523
ENGINE ReplacingMergeTree

services/libs/tinybird/pipes/org_page_projects.pipe

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,22 @@ TAGS "Organization page"
77
NODE org_page_projects_main
88
SQL >
99
%
10-
SELECT projectSlug, projectName, projectLogo, activityCount, contributorCount
10+
SELECT
11+
projectSlug,
12+
projectName,
13+
projectLogo,
14+
activityCount,
15+
contributorCount,
16+
maintainersCount,
17+
totalContributors,
18+
orgContributors,
19+
totalCommits,
20+
orgCommits,
21+
totalPrsOpened,
22+
orgPrsOpened,
23+
technicalScore
1124
FROM org_page_projects_copy_ds FINAL
1225
WHERE organizationId = {{ String(orgId, '', description="Organization ID", required=True) }}
13-
ORDER BY activityCount DESC
14-
LIMIT 20
26+
ORDER BY technicalScore DESC, activityCount DESC
27+
LIMIT {{ Int32(limit, 21, description="Page size + 1 for hasMore detection") }}
28+
OFFSET {{ Int32(offset, 0, description="Pagination offset") }}

services/libs/tinybird/pipes/org_page_projects_copy_pipe.pipe

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,59 @@ SQL >
3535
LEFT JOIN insights_projects_populated_ds p ON a.segmentId = p.segmentId
3636
WHERE p.slug != ''
3737

38+
NODE org_page_projects_with_scores
39+
DESCRIPTION >
40+
Join with org_dash_metric_copy_ds to compute technical influence score
41+
42+
SQL >
43+
SELECT
44+
w.organizationId,
45+
w.segmentId,
46+
w.projectSlug,
47+
w.projectName,
48+
w.projectLogo,
49+
w.activityCount,
50+
w.contributorCount,
51+
ifNull(m.maintainersCount, 0) AS maintainersCount,
52+
ifNull(m.contributorCount, 0) AS totalContributors,
53+
ifNull(m.orgContributorCount, 0) AS orgContributors,
54+
ifNull(m.commits, 0) AS totalCommits,
55+
ifNull(m.orgCommits, 0) AS orgCommits,
56+
ifNull(m.prsOpened, 0) AS totalPrsOpened,
57+
ifNull(m.orgPrsOpened, 0) AS orgPrsOpened,
58+
(
59+
-- Maintainers: 3 pts if org has at least 1 maintainer
60+
CASE WHEN ifNull(m.maintainersCount, 0) >= 1 THEN 3 ELSE 0 END
61+
-- Contributors: % of org contributors vs total
62+
+ CASE
63+
WHEN ifNull(m.contributorCount, 0) = 0 THEN 0
64+
WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 20 THEN 3
65+
WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 5 THEN 2
66+
WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 1 THEN 1
67+
ELSE 0
68+
END
69+
-- Commits: % of org commits vs total
70+
+ CASE
71+
WHEN ifNull(m.commits, 0) = 0 THEN 0
72+
WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 20 THEN 3
73+
WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 5 THEN 2
74+
WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 1 THEN 1
75+
ELSE 0
76+
END
77+
-- PRs opened: % of org PRs vs total
78+
+ CASE
79+
WHEN ifNull(m.prsOpened, 0) = 0 THEN 0
80+
WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 20 THEN 3
81+
WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 5 THEN 2
82+
WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 1 THEN 1
83+
ELSE 0
84+
END
85+
) AS technicalScore,
86+
w.computedAt
87+
FROM org_page_projects_with_meta w
88+
LEFT JOIN org_dash_metric_copy_ds m
89+
ON w.organizationId = m.organizationId AND w.projectSlug = m.slug
90+
3891
TYPE COPY
3992
TARGET_DATASOURCE org_page_projects_copy_ds
4093
COPY_MODE replace

0 commit comments

Comments
 (0)