Skip to content

Commit 06000ac

Browse files
fix: populate GitHub subscriber checks from GraphQL and refresh cache version
1 parent c837381 commit 06000ac

6 files changed

Lines changed: 23 additions & 6 deletions

File tree

scripts/check-modules/__tests__/result-markdown.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("result-markdown", () => {
4646
name: "MMM-Quiet",
4747
maintainer: "Dana",
4848
url: "https://github.com/example/MMM-Quiet",
49-
issues: ["GitHub reports 0 watchers; maintainer notifications may be missed."]
49+
issues: ["GitHub reports 0 subscribers (Watch); maintainer notifications may be missed."]
5050
}
5151
]);
5252
});

scripts/check-modules/result-markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function collectIssueSummaries(modules: unknown[]): IssueSummary[] {
5757
const stageModule = module as ProcessedModuleLike;
5858
const issues = normalizeIssuesInput(stageModule.issues);
5959
const watcherIssue = isGitHubUrl(stageModule.url) && stageModule.watchersCount === 0
60-
? "GitHub reports 0 watchers; maintainer notifications may be missed."
60+
? "GitHub reports 0 subscribers (Watch); maintainer notifications may be missed."
6161
: null;
6262

6363
const combinedIssues = watcherIssue ? [...issues, watcherIssue] : issues;

scripts/collect-metadata/__tests__/runtime.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test("runCollectMetadata retries repositories even when a stale negative cache e
1616
const cachePath = join(cacheDir, "repository-api-cache.json");
1717
const repoId = "MagicMirrorOrg/MagicMirror";
1818
const cachePayload = {
19-
version: "repository-api/v1",
19+
version: "repository-api/v2",
2020
generatedAt: "2026-06-24T00:00:00.000Z",
2121
entries: {
2222
[repoId]: {

scripts/collect-metadata/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ interface GraphQlRepoData {
5252
hasIssuesEnabled?: boolean;
5353
isArchived?: boolean;
5454
stargazerCount?: number;
55+
watchers?: { totalCount?: number };
5556
[key: string]: unknown;
5657
}
5758

@@ -143,7 +144,7 @@ const httpClient = createHttpClient({ rateLimiter });
143144
const repositoryCache = createPersistentCache({
144145
filePath: REPOSITORY_CACHE_PATH,
145146
defaultTtlMs: REPOSITORY_CACHE_TTL_MS,
146-
version: "repository-api/v1"
147+
version: "repository-api/v2"
147148
});
148149

149150
/**
@@ -185,6 +186,7 @@ async function fetchGitHubBatch(modules: EnrichedModule[]): Promise<GitHubBatchR
185186
${alias}: repository(owner: "${owner}", name: "${name}") {
186187
openIssues: issues(states: OPEN) { totalCount }
187188
stargazerCount
189+
watchers { totalCount }
188190
isArchived
189191
isDisabled
190192
hasIssuesEnabled

scripts/updateRepositoryApiData/__tests__/api.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,16 @@ describe("updateRepositoryApiData/api", () => {
3939

4040
assert.strictEqual(typeof normalized.watchersCount, "undefined");
4141
});
42+
43+
it("uses GraphQL watchers totalCount when subscribers_count is missing", () => {
44+
const normalized = normalizeRepositoryData({
45+
stargazers_count: 12,
46+
watchers: { totalCount: 4 },
47+
has_issues: true,
48+
archived: false,
49+
defaultBranchRef: { target: { committedDate: "2026-01-01T00:00:00.000Z" } }
50+
}, null, "github");
51+
52+
assert.strictEqual(normalized.watchersCount, 4);
53+
});
4254
});

scripts/updateRepositoryApiData/api.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ interface RepositoryApiData {
4343
stargazers_count?: number;
4444
stars_count?: number;
4545
subscribers_count?: number;
46+
watchers?: { totalCount?: number };
4647
watchers_count?: number;
4748
[key: string]: unknown;
4849
}
@@ -186,8 +187,10 @@ export function normalizeRepositoryData(data: RepositoryApiData, branchData: Rep
186187
?? data.pushed_at
187188
?? data.pushedAt
188189
?? null;
189-
// Only trust an explicit API value. GraphQL batch payloads do not provide subscribers_count.
190-
watchersCount = typeof data.subscribers_count === "number" ? data.subscribers_count : undefined;
190+
// Prefer the REST subscribers_count, then GraphQL watchers.totalCount.
191+
watchersCount = typeof data.subscribers_count === "number"
192+
? data.subscribers_count
193+
: (typeof data.watchers?.totalCount === "number" ? data.watchers.totalCount : undefined);
191194
break;
192195
case "gitlab":
193196
stars = data.star_count ?? 0;

0 commit comments

Comments
 (0)