mirror of
https://github.com/gethomepage/homepage.git
synced 2026-10-15 23:19:57 -07:00
Fix: use x-total-count header for correct gitea totals (#7227)
This commit is contained in:
+16
-11
@@ -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,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user