mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-09 15:17:49 +02:00
fix: improve performance PRs
This commit is contained in:
+38
-56
@@ -39,38 +39,20 @@ export default class PullRequest {
|
|||||||
const octokit = new Octokit({ auth });
|
const octokit = new Octokit({ auth });
|
||||||
const [owner, repo] = this._model.source.repositoryFullName.split("/");
|
const [owner, repo] = this._model.source.repositoryFullName.split("/");
|
||||||
const pull_number = this._model.source.pullRequestId;
|
const pull_number = this._model.source.pullRequestId;
|
||||||
const prInfo = await octokit.rest.pulls.get({
|
const [prInfo, comments, diff] = await Promise.all([
|
||||||
owner,
|
octokit.rest.pulls.get({
|
||||||
repo,
|
owner,
|
||||||
pull_number,
|
repo,
|
||||||
});
|
pull_number,
|
||||||
|
}),
|
||||||
prInfo.data.updated_at;
|
octokit.rest.issues.listComments({
|
||||||
prInfo.data.draft;
|
owner,
|
||||||
prInfo.data.merged;
|
repo,
|
||||||
prInfo.data.merged_at;
|
issue_number: pull_number,
|
||||||
prInfo.data.state;
|
per_page: 100,
|
||||||
prInfo.data.base.repo.full_name;
|
}),
|
||||||
prInfo.data.head.repo.full_name;
|
got(`https://github.com/${owner}/${repo}/pull/${pull_number}.diff`),
|
||||||
const comments = await octokit.rest.issues.listComments({
|
]);
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: pull_number,
|
|
||||||
per_page: 100,
|
|
||||||
});
|
|
||||||
// const commits = await octokit.rest.pulls.listCommits({
|
|
||||||
// owner,
|
|
||||||
// repo,
|
|
||||||
// pull_number,
|
|
||||||
// per_page: 100,
|
|
||||||
// });
|
|
||||||
// const files = await octokit.rest.pulls.listFiles({
|
|
||||||
// owner,
|
|
||||||
// repo,
|
|
||||||
// pull_number,
|
|
||||||
// per_page: 100,
|
|
||||||
// });
|
|
||||||
const diff = await got(prInfo.data.diff_url);
|
|
||||||
this._model.pullRequest = {
|
this._model.pullRequest = {
|
||||||
diff: diff.body,
|
diff: diff.body,
|
||||||
title: prInfo.data.title,
|
title: prInfo.data.title,
|
||||||
@@ -140,10 +122,10 @@ export default class PullRequest {
|
|||||||
yesterday.setDate(yesterday.getDate() - 1);
|
yesterday.setDate(yesterday.getDate() - 1);
|
||||||
if (
|
if (
|
||||||
opt?.force ||
|
opt?.force ||
|
||||||
(this._model.options.update && this._model.lastView < yesterday)
|
(this._model.options.update && this._model.anonymizeDate < yesterday)
|
||||||
) {
|
) {
|
||||||
await this.download();
|
await this.download();
|
||||||
this._model.lastView = new Date();
|
this._model.anonymizeDate = new Date();
|
||||||
await this._model.save();
|
await this._model.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,28 +207,6 @@ export default class PullRequest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Getters ********/
|
|
||||||
|
|
||||||
get pullRequestId() {
|
|
||||||
return this._model.pullRequestId;
|
|
||||||
}
|
|
||||||
|
|
||||||
get options() {
|
|
||||||
return this._model.options;
|
|
||||||
}
|
|
||||||
|
|
||||||
get source() {
|
|
||||||
return this._model.source;
|
|
||||||
}
|
|
||||||
|
|
||||||
get model() {
|
|
||||||
return this._model;
|
|
||||||
}
|
|
||||||
|
|
||||||
get status() {
|
|
||||||
return this._model.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
content() {
|
content() {
|
||||||
const output: any = {
|
const output: any = {
|
||||||
anonymizeDate: this._model.anonymizeDate,
|
anonymizeDate: this._model.anonymizeDate,
|
||||||
@@ -288,6 +248,28 @@ export default class PullRequest {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Getters ********/
|
||||||
|
|
||||||
|
get pullRequestId() {
|
||||||
|
return this._model.pullRequestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
get options() {
|
||||||
|
return this._model.options;
|
||||||
|
}
|
||||||
|
|
||||||
|
get source() {
|
||||||
|
return this._model.source;
|
||||||
|
}
|
||||||
|
|
||||||
|
get model() {
|
||||||
|
return this._model;
|
||||||
|
}
|
||||||
|
|
||||||
|
get status() {
|
||||||
|
return this._model.status;
|
||||||
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
pullRequestId: this._model.pullRequestId,
|
pullRequestId: this._model.pullRequestId,
|
||||||
|
|||||||
Reference in New Issue
Block a user