Add support for PRs missing authors (a.k.a. authored by ghost)

This commit is contained in:
Yuri Sizov
2022-07-20 16:14:21 +03:00
parent 53927933e4
commit 6f4cec6e6c
2 changed files with 23 additions and 8 deletions

View File

@@ -111,7 +111,7 @@ async function checkRates() {
}
const data = await res.json();
logResponse(data, "_rate_limit");
await logResponse(data, "_rate_limit");
handleErrors(data);
const rate_limit = data.data["rateLimit"];
@@ -227,7 +227,7 @@ async function fetchPulls(page) {
}
const data = await res.json();
logResponse(data, `data_page_${page}`);
await logResponse(data, `data_page_${page}`);
handleErrors(data);
const rate_limit = data.data["rateLimit"];
@@ -279,16 +279,22 @@ function processPulls(pullsRaw) {
// Compose and link author information.
const author = {
"id": item.author.id,
"user": item.author.login,
"avatar": item.author.avatarUrl,
"url": item.author.url,
"id": "",
"user": "ghost",
"avatar": "https://avatars.githubusercontent.com/u/10137?v=4",
"url": "https://github.com/ghost",
"pull_count": 0,
};
if (item.author != null) {
author["id"] = item.author.id;
author["user"] = item.author.login;
author["avatar"] = item.author.avatarUrl;
author["url"] = item.author.url;
}
pr.authored_by = author.id;
// Store the author if they haven't been stored.
if (typeof authors[author.id] == "undefined") {
if (typeof authors[author.id] === "undefined") {
authors[author.id] = author;
}
authors[author.id].pull_count++;
@@ -355,7 +361,7 @@ function processPulls(pullsRaw) {
};
// Store the team if it hasn't been stored before.
if (typeof teams[team.id] == "undefined") {
if (typeof teams[team.id] === "undefined") {
teams[team.id] = team;
}
teams[team.id].pull_count++;

View File

@@ -10,6 +10,7 @@ export default class PullRequestItem extends LitElement {
--draft-font-color: #ffcc31;
--draft-background-color: #9db3c0;
--stats-background-color: #f9fafa;
--ghost-font-color: #738b99;
--mergeable-unknown-color: #939fa3;
--mergeable-no-color: #de1600;
@@ -34,6 +35,7 @@ export default class PullRequestItem extends LitElement {
--draft-font-color: #e0c537;
--draft-background-color: #1e313c;
--stats-background-color: #0f1316;
--ghost-font-color: #495d68;
--mergeable-unknown-color: #4e5659;
--mergeable-no-color: #d31a3b;
@@ -161,6 +163,10 @@ export default class PullRequestItem extends LitElement {
content: "★";
color: var(--draft-font-color);
}
:host .pr-author-value--ghost {
color: var(--ghost-font-color);
font-weight: 600;
}
:host .pr-links {
font-size: 13px;
@@ -372,6 +378,9 @@ export default class PullRequestItem extends LitElement {
if (this.author.pull_count > 40) {
authorClassList.push("pr-author-value--hot");
}
if (this.author.id === "") {
authorClassList.push("pr-author-value--ghost");
}
// Keep it to two columns, but if there isn't enough labels, keep it to one.
let labels_height = Math.ceil(this.labels.length / 2) * 20;