gitea: a merge poll looks only at repositories that moved, one pass at a time
With the poll the only announcer of a merge, its cost showed: every 30 s it asked every repository for its pull requests, a pass outlasted the tick, and passes piled up beside each other — a merge was announced four and a half minutes late, and two passes at once could each announce it. A pass now asks only repositories updated since a minute before the last look, and the next pass starts when this one ends. hq issue 250.
This commit is contained in:
@@ -17,6 +17,8 @@ export interface GiteaRepo {
|
||||
description?: string;
|
||||
html_url: string;
|
||||
default_branch?: string;
|
||||
/** When anything last moved in it — a push, and so a merge. */
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
/** An issue, with its labels flattened to names. */
|
||||
@@ -356,6 +358,7 @@ export class GiteaClient {
|
||||
description: r.description || undefined,
|
||||
html_url: r.html_url,
|
||||
default_branch: r.default_branch,
|
||||
updated_at: r.updated_at ?? undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -598,3 +601,11 @@ export class GiteaAdmin {
|
||||
GiteaAdmin.fail(`/admin/users/${username}`, res);
|
||||
}
|
||||
}
|
||||
|
||||
/** The repositories that moved at or after a moment: every one when there is no moment yet, and one whose
|
||||
* update time is not known, so a forge that does not say is asked as before (novox/hq issue 250). */
|
||||
export function movedSince(repos: GiteaRepo[], floor: string): GiteaRepo[] {
|
||||
if (!floor) return repos;
|
||||
const at = Date.parse(floor);
|
||||
return repos.filter((r) => !r.updated_at || !(Date.parse(r.updated_at) < at));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user