Fix: use x-total-count header for correct gitea totals (#7227)

This commit is contained in:
shamoon
2026-10-08 10:10:30 -07:00
committed by GitHub
parent fec0f5d8b2
commit 97db55ab36
6 changed files with 61 additions and 39 deletions
+16 -11
View File
@@ -1,26 +1,31 @@
import { asJson } from "utils/proxy/api-helpers";
import genericProxyHandler from "utils/proxy/handlers/generic";
// Get total from header to avoid pagination limit
export function totalCount(data, headers) {
const count = parseInt(headers?.["x-total-count"], 10);
return { count: Number.isNaN(count) ? null : count };
}
const widget = {
api: "{url}/api/v1/{endpoint}?access_token={key}",
proxyHandler: genericProxyHandler,
mappings: {
notifications: {
endpoint: "notifications",
endpoint: "notifications?limit=1",
map: totalCount,
},
issues: {
endpoint: "repos/issues/search",
map: (data) => {
const items = asJson(data);
return {
pulls: items.filter((issue) => issue.pull_request),
issues: items.filter((issue) => !issue.pull_request),
};
},
endpoint: "repos/issues/search?type=issues&limit=1",
map: totalCount,
},
pulls: {
endpoint: "repos/issues/search?type=pulls&limit=1",
map: totalCount,
},
repositories: {
endpoint: "repos/search",
endpoint: "repos/search?limit=1",
map: totalCount,
},
},
};