@@ -19,12 +19,13 @@ SQL >
1919
2020NODE org_page_projects_with_meta
2121DESCRIPTION >
22- Enrich with project name, logo and slug from insights_projects_populated_ds
22+ Enrich with project name, logo, slug, and id from insights_projects_populated_ds
2323
2424SQL >
2525 SELECT
2626 a.organizationId,
2727 a.segmentId,
28+ p.id AS projectId,
2829 p.slug AS projectSlug,
2930 p.name AS projectName,
3031 p.logoUrl AS projectLogo,
@@ -35,19 +36,86 @@ SQL >
3536 LEFT JOIN insights_projects_populated_ds p ON a.segmentId = p.segmentId
3637 WHERE p.slug != ''
3738
39+ NODE org_page_projects_score_project_code_activity
40+ DESCRIPTION >
41+ Project-level code-only activity totals over the last 24 months, used only for the technical score
42+
43+ SQL >
44+ SELECT
45+ segmentId,
46+ countIf(
47+ case when activityId != '' then activityId else null end, type = 'authored-commit'
48+ ) AS scoreCommits,
49+ countIf(
50+ case when activityId != '' then activityId else null end,
51+ type IN ('pull_request-opened', 'merge_request-opened', 'changeset-created')
52+ ) AS scorePrsOpened,
53+ uniqIf(
54+ memberId,
55+ type
56+ IN ('authored-commit', 'pull_request-opened', 'merge_request-opened', 'changeset-created')
57+ ) AS scoreContributorCount
58+ FROM activityRelations_deduplicated_cleaned_bucket_union
59+ WHERE
60+ timestamp >= toStartOfDay(now() - toIntervalDay(730))
61+ AND timestamp < toStartOfDay(now() + toIntervalDay(1))
62+ GROUP BY segmentId
63+
64+ NODE org_page_projects_score_org_code_activity
65+ DESCRIPTION >
66+ Org-level code-only activity totals over the last 24 months, used only for the technical score
67+
68+ SQL >
69+ SELECT
70+ segmentId,
71+ organizationId,
72+ countIf(
73+ case when activityId != '' then activityId else null end, type = 'authored-commit'
74+ ) AS scoreOrgCommits,
75+ countIf(
76+ case when activityId != '' then activityId else null end,
77+ type IN ('pull_request-opened', 'merge_request-opened', 'changeset-created')
78+ ) AS scoreOrgPrsOpened,
79+ uniqIf(
80+ memberId,
81+ type
82+ IN ('authored-commit', 'pull_request-opened', 'merge_request-opened', 'changeset-created')
83+ ) AS scoreOrgContributorCount
84+ FROM activityRelations_deduplicated_cleaned_bucket_union
85+ WHERE
86+ organizationId != ''
87+ AND timestamp >= toStartOfDay(now() - toIntervalDay(730))
88+ AND timestamp < toStartOfDay(now() + toIntervalDay(1))
89+ GROUP BY segmentId, organizationId
90+
91+ NODE org_page_projects_score_active_maintainers
92+ DESCRIPTION >
93+ Active maintainers per (insightsProjectId, organizationId): active means started and not ended more than 24 months ago
94+
95+ SQL >
96+ SELECT insightsProjectId, organizationId, uniq(memberId) AS scoreMaintainersCount
97+ FROM maintainers_roles_copy_ds
98+ WHERE
99+ role = 'maintainer'
100+ AND organizationId != ''
101+ AND startDate <= now()
102+ AND (toYear(endDate) <= 1970 OR endDate >= now() - toIntervalDay(730))
103+ GROUP BY insightsProjectId, organizationId
104+
38105NODE org_page_projects_with_scores
39106DESCRIPTION >
40- Join with org_dash_metric_copy_ds to compute technical influence score
107+ Compute technical influence score from spec-compliant 24-month code-only inputs.
108+ Display columns (maintainersCount, totalContributors, etc.) remain sourced from org_dash_metric_copy_ds.
41109
42110SQL >
43111 SELECT
44- w.organizationId,
45- w.segmentId,
46- w.projectSlug,
47- w.projectName,
48- w.projectLogo,
49- w.activityCount,
50- w.contributorCount,
112+ w.organizationId AS organizationId ,
113+ w.segmentId AS segmentId ,
114+ w.projectSlug AS projectSlug ,
115+ w.projectName AS projectName ,
116+ w.projectLogo AS projectLogo ,
117+ w.activityCount AS activityCount ,
118+ w.contributorCount AS contributorCount ,
51119 ifNull(m.maintainersCount, 0) AS maintainersCount,
52120 ifNull(m.contributorCount, 0) AS totalContributors,
53121 ifNull(m.orgContributorCount, 0) AS orgContributors,
@@ -56,48 +124,47 @@ SQL >
56124 ifNull(m.prsOpened, 0) AS totalPrsOpened,
57125 ifNull(m.orgPrsOpened, 0) AS orgPrsOpened,
58126 (
59- -- Maintainers: 3 pts if org has at least 1 maintainer
60- -- Contributors: % of org contributors vs total
61- CASE WHEN ifNull(m.maintainersCount, 0) >= 1 THEN 3 ELSE 0 END + CASE
62- WHEN ifNull(m.contributorCount, 0) = 0
63- THEN 0
64- WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 20
65- THEN 3
66- WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 5
67- THEN 2
68- WHEN ifNull(m.orgContributorCount, 0) * 100.0 / m.contributorCount >= 1
69- THEN 1
70- ELSE 0
127+ -- Maintainers: 3 pts if org has at least 1 active maintainer (24-month window)
128+ -- Contributors: 0 if no share; 1.1 if share in (0, 0.1%]; share + 1.0 otherwise
129+ CASE WHEN ifNull(mt.scoreMaintainersCount, 0) >= 1 THEN 3.0 ELSE 0.0 END + CASE
130+ WHEN
131+ ifNull(pa.scoreContributorCount, 0) = 0
132+ OR ifNull(oa.scoreOrgContributorCount, 0) = 0
133+ THEN 0.0
134+ WHEN oa.scoreOrgContributorCount * 100.0 / pa.scoreContributorCount <= 0.1
135+ THEN 1.1
136+ ELSE round(oa.scoreOrgContributorCount * 100.0 / pa.scoreContributorCount + 1.0, 1)
71137 END
72- -- Commits: % of org commits vs total
138+ -- Commits: same formula
73139 + CASE
74- WHEN ifNull(m.commits, 0) = 0
75- THEN 0
76- WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 20
77- THEN 3
78- WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 5
79- THEN 2
80- WHEN ifNull(m.orgCommits, 0) * 100.0 / m.commits >= 1
81- THEN 1
82- ELSE 0
140+ WHEN ifNull(pa.scoreCommits, 0) = 0 OR ifNull(oa.scoreOrgCommits, 0) = 0
141+ THEN 0.0
142+ WHEN oa.scoreOrgCommits * 100.0 / pa.scoreCommits <= 0.1
143+ THEN 1.1
144+ ELSE round(oa.scoreOrgCommits * 100.0 / pa.scoreCommits + 1.0, 1)
83145 END
84- -- PRs opened: % of org PRs vs total
146+ -- PRs opened: same formula
85147 + CASE
86- WHEN ifNull(m.prsOpened, 0) = 0
87- THEN 0
88- WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 20
89- THEN 3
90- WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 5
91- THEN 2
92- WHEN ifNull(m.orgPrsOpened, 0) * 100.0 / m.prsOpened >= 1
93- THEN 1
94- ELSE 0
148+ WHEN ifNull(pa.scorePrsOpened, 0) = 0 OR ifNull(oa.scoreOrgPrsOpened, 0) = 0
149+ THEN 0.0
150+ WHEN oa.scoreOrgPrsOpened * 100.0 / pa.scorePrsOpened <= 0.1
151+ THEN 1.1
152+ ELSE round(oa.scoreOrgPrsOpened * 100.0 / pa.scorePrsOpened + 1.0, 1)
95153 END
96154 ) AS technicalScore,
97- w.computedAt
155+ w.computedAt AS computedAt
98156 FROM org_page_projects_with_meta w
99157 LEFT JOIN
100158 org_dash_metric_copy_ds m ON w.organizationId = m.organizationId AND w.projectSlug = m.slug
159+ LEFT JOIN org_page_projects_score_project_code_activity pa ON w.segmentId = pa.segmentId
160+ LEFT JOIN
161+ org_page_projects_score_org_code_activity oa
162+ ON w.segmentId = oa.segmentId
163+ AND w.organizationId = oa.organizationId
164+ LEFT JOIN
165+ org_page_projects_score_active_maintainers mt
166+ ON w.projectId = mt.insightsProjectId
167+ AND w.organizationId = mt.organizationId
101168
102169TYPE COPY
103170TARGET_DATASOURCE org_page_projects_copy_ds
0 commit comments