Skip to content

Commit 72fa39e

Browse files
committed
feat: Enhance Updater with Private Contributions & Metadata (#9118)
- Added restrictedContributionsCount to GraphQL query - Added 'py' (Private Years) array to minified output - Updated 'tc' (Total) and 'y' (Years) to include private stats - Added 'h' (isHireable), 's' (hasSponsorsListing), 't' (twitter), 'w' (website)
1 parent d038e64 commit 72fa39e

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

apps/devindex/services/Updater.mjs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class Updater extends Base {
176176
bio
177177
followers { totalCount }
178178
isHireable
179+
hasSponsorsListing
179180
twitterUsername
180181
websiteUrl
181182
socialAccounts(first: 5) {
@@ -215,7 +216,7 @@ class Updater extends Base {
215216

216217
if (!profileRes?.user) return null;
217218

218-
const { createdAt, avatarUrl, name, location, company, bio, followers, socialAccounts } = profileRes.user;
219+
const { createdAt, avatarUrl, name, location, company, bio, followers, socialAccounts, isHireable, hasSponsorsListing, twitterUsername, websiteUrl } = profileRes.user;
219220
const startYear = new Date(createdAt).getFullYear();
220221
const currentYear = new Date().getFullYear();
221222

@@ -244,6 +245,7 @@ class Updater extends Base {
244245
totalPullRequestContributions
245246
totalPullRequestReviewContributions
246247
totalRepositoryContributions
248+
restrictedContributionsCount
247249
}`;
248250
}
249251
query += ` } }`;
@@ -268,24 +270,27 @@ class Updater extends Base {
268270
let total = 0;
269271
const yearsArr = [];
270272
const commitsArr = [];
273+
const privateArr = [];
271274

272275
// Ensure years are sorted and fill the array sequentially from startYear
273276
for (let year = startYear; year <= currentYear; year++) {
274277
const key = `y${year}`;
275278
const collection = contribData[key];
276279

277280
const commits = collection?.totalCommitContributions || 0;
281+
const privateStats = collection?.restrictedContributionsCount || 0;
278282

279283
// Sum up the lightweight counters
280-
// We expressly EXCLUDE restrictedContributionsCount as we don't have access (and it triggers 502s)
281284
const val = (commits) +
282285
(collection?.totalIssueContributions || 0) +
283286
(collection?.totalPullRequestContributions || 0) +
284287
(collection?.totalPullRequestReviewContributions || 0) +
285-
(collection?.totalRepositoryContributions || 0);
288+
(collection?.totalRepositoryContributions || 0) +
289+
privateStats;
286290

287291
yearsArr.push(val);
288292
commitsArr.push(commits);
293+
privateArr.push(privateStats);
289294
total += val;
290295
}
291296

@@ -301,7 +306,8 @@ class Updater extends Base {
301306
fy: startYear,
302307
lu: new Date().toISOString(),
303308
y: yearsArr,
304-
cy: commitsArr
309+
cy: commitsArr,
310+
py: privateArr
305311
};
306312

307313
if (name && name !== username) minified.n = name;
@@ -319,6 +325,12 @@ class Updater extends Base {
319325
if (followers?.totalCount > 0) minified.fl = followers.totalCount;
320326
if (linkedin_url) minified.li = linkedin_url;
321327

328+
// Metadata
329+
if (isHireable) minified.h = 1;
330+
if (hasSponsorsListing) minified.s = 1;
331+
if (twitterUsername) minified.t = twitterUsername;
332+
if (websiteUrl) minified.w = websiteUrl;
333+
322334
if (orgs.length > 0) {
323335
// Take top 5, map to [login, id]
324336
minified.o = orgs.slice(0, 5).map(org => [

0 commit comments

Comments
 (0)