Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/github/backfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@
const query = `query GittensoryRepoTotals {
rateLimit { remaining resetAt }
repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(name)}) {
issues(states: OPEN) { totalCount }
issues(states: OPEN, filter: {issueTypes: ISSUE}) { totalCount }
openPullRequests: pullRequests(states: OPEN) { totalCount }
mergedPullRequests: pullRequests(states: MERGED) { totalCount }
closedPullRequests: pullRequests(states: CLOSED) { totalCount }
Expand Down Expand Up @@ -1230,9 +1230,10 @@
for (;;) {
const query = `query GittensoryOpenIssuesSupplement {
repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(name)}) {
issues(states: OPEN, first: 100${after}) {
issues(states: OPEN, filter: {issueTypes: ISSUE}, first: 100${after}) {
pageInfo { hasNextPage endCursor }
nodes {
__typename
number
title
state
Expand All @@ -1251,6 +1252,7 @@
const response = await githubGraphQl<GitHubOpenIssuesResponse>(env, query, token);
const issues = response.data?.repository?.issues;
for (const issue of issues?.nodes ?? []) {
if (issue?.__typename === "PullRequest") continue;

Check failure on line 1255 in src/github/backfill.ts

View workflow job for this annotation

GitHub Actions / validate

Property '__typename' does not exist on type '{ number?: number; title?: string; state?: string; url?: string; body?: string | null; createdAt?: string | null; updatedAt?: string | null; authorAssociation?: string | null; author?: { login?: string | null; } | null; labels?: { ...; } | null; }'.
if (!issue?.number || existingNumbers.has(issue.number)) continue;
const payload: GitHubIssuePayload = {
number: issue.number,
Expand Down
33 changes: 27 additions & 6 deletions test/unit/backfill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -945,12 +945,33 @@ describe("GitHub backfill", () => {

expect(result).toMatchObject({ status: "queued", totals: { openIssuesTotal: 2911, openPullRequestsTotal: 167 } });
expect(await listRepoSyncStates(env)).toMatchObject([{ status: "running", openIssuesCount: 1100, openPullRequestsCount: 167, lastCompletedAt: "2026-05-24T00:00:00.000Z" }]);
expect(sent).toEqual(
expect.arrayContaining([
expect.objectContaining({ type: "backfill-repo-segment", repoFullName: "JSONbored/gittensory", segment: "open_issues", mode: "resume", force: true }),
expect.objectContaining({ type: "backfill-repo-segment", repoFullName: "JSONbored/gittensory", segment: "open_pull_requests", mode: "resume", force: true }),
]),
);
});

it("persists openIssuesTotal without subtracting open pull requests from issues GraphQL total", async () => {
const env = createTestEnv({ GITHUB_PUBLIC_TOKEN: "public-token" });
await seedRegisteredRepo(env);
let graphqlBody = "";
vi.stubGlobal("fetch", async (input: RequestInfo | URL, init?: RequestInit) => {
const url = input.toString();
if (url === "https://api.github.com/graphql") {
graphqlBody = String(init?.body ?? "");
return githubTotalsResponse({ openIssues: 10, openPullRequests: 3, mergedPullRequests: 0, closedPullRequests: 0, labels: 1 });
}
return new Response("unexpected", { status: 500 });
});

const result = await enqueueRepositoryOpenDataBackfill(env, {
repoFullName: "JSONbored/gittensory",
requestedBy: "api",
mode: "full",
force: true,
});

expect(result.totals?.openIssuesTotal).toBe(10);
expect(graphqlBody).toContain("issueTypes");
expect(await listLatestRepoGithubTotalsSnapshots(env)).toMatchObject([
{ repoFullName: "JSONbored/gittensory", openIssuesTotal: 10, openPullRequestsTotal: 3 },
]);
});

it("drains open issue segments against GitHub totals without counting PR rows from /issues", async () => {
Expand Down
Loading