mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-19 22:27:20 +02:00
perf: bound request work and resource usage (#866)
* perf: bound request work and resource usage * fix: address performance review regressions * fix: guard content expiration and dashboard state * fix: tolerate cache outages and retire derived paths * fix: revalidate expiration claims and status pagination * fix: retry interrupted repository metadata cleanup * fix: retire obsolete content cache storage * fix: activate tree metadata and recheck expiration claims * fix: fence cache publication across expiration * fix: recover staged trees and enforce cache lifecycle cleanup * fix: prune expired transforms during database outages * fix: finish conference removals and reload expiration candidates
This commit is contained in:
1 parent
32722169a2
commit
6434337923
74 files changed
+4752
-553
No files matched your search
+26
-4
@@ -1,3 +1,5 @@
|
||||
import { isConnected } from "../server/database";
|
||||
import { expireEmbeddedContent } from "./content-expiration";
|
||||
import { boundAppToken } from "./github-app";
|
||||
import { getCredentialToken } from "./credentials";
|
||||
import { RepositoryStatus } from "./types";
|
||||
@@ -121,7 +123,7 @@ export default class PullRequest {
|
||||
this._model.options.expirationDate
|
||||
) {
|
||||
if (this._model.options.expirationDate <= new Date()) {
|
||||
await this.expire();
|
||||
await this.markExpired();
|
||||
}
|
||||
}
|
||||
if (
|
||||
@@ -228,10 +230,30 @@ export default class PullRequest {
|
||||
/**
|
||||
* Expire the pullRequest
|
||||
*/
|
||||
async markExpired() {
|
||||
const now = new Date();
|
||||
if (isConnected) {
|
||||
const result = await AnonymizedPullRequestModel.updateOne({ _id: this.model._id,
|
||||
status: RepositoryStatus.READY, "options.expirationMode": { $ne: "never" },
|
||||
"options.expirationDate": { $lte: now },
|
||||
}, { $set: { status: RepositoryStatus.EXPIRING, statusDate: now } }).exec();
|
||||
if (!result.matchedCount) {
|
||||
const current = await AnonymizedPullRequestModel.findById(this.model._id).exec();
|
||||
if (!current) throw new AnonymousError("pull_request_expired", { object: this, httpStatus: 410 });
|
||||
this._model = current;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.model.status = RepositoryStatus.EXPIRING;
|
||||
this.model.statusDate = now;
|
||||
}
|
||||
|
||||
async expire() {
|
||||
await this.updateStatus(RepositoryStatus.EXPIRING);
|
||||
await this.resetSate();
|
||||
await this.updateStatus(RepositoryStatus.EXPIRED);
|
||||
await expireEmbeddedContent(AnonymizedPullRequestModel, this.model, {
|
||||
"pullRequest.comments": [], "pullRequest.body": "", "pullRequest.title": "", "pullRequest.diff": "",
|
||||
"pullRequest.baseRepositoryFullName": "", "pullRequest.headRepositoryFullName": "",
|
||||
"pullRequest.merged": false, "pullRequest.state": "closed", "pullRequest.draft": false,
|
||||
}, { "pullRequest.mergedDate": "" });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user