Added pr reviews to stats (#1404)

* Added pr reviews to stats

* Add 'show' query parameter

* Fix show test

* refactoring

* cleanup

* refactor: restructure stats-card code

---------

Co-authored-by: Markus <markus.tyrkko@gmail.com>
Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
Co-authored-by: rickstaa <rick.staa@outlook.com>
This commit is contained in:
Markus Tyrkkö
2023-06-15 09:35:09 +02:00
committed by GitHub
co-authored by Markus Alexandr rickstaa
parent c86cc72df2
commit 1bb65ddc29
10 changed files with 112 additions and 34 deletions
+45 -33
View File
@@ -85,6 +85,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
totalCommits,
totalIssues,
totalPRs,
totalReviews,
contributedTo,
rank,
} = stats;
@@ -111,6 +112,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
locale,
disable_animations = false,
rank_icon = "default",
show_total_reviews = false,
} = options;
const lheight = parseInt(String(line_height), 10);
@@ -136,40 +138,50 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
});
// Meta data for creating text nodes with createTextNode function
const STATS = {
stars: {
icon: icons.star,
label: i18n.t("statcard.totalstars"),
value: totalStars,
id: "stars",
},
commits: {
icon: icons.commits,
label: `${i18n.t("statcard.commits")}${
include_all_commits ? "" : ` (${new Date().getFullYear()})`
}`,
value: totalCommits,
id: "commits",
},
prs: {
icon: icons.prs,
label: i18n.t("statcard.prs"),
value: totalPRs,
id: "prs",
},
issues: {
icon: icons.issues,
label: i18n.t("statcard.issues"),
value: totalIssues,
id: "issues",
},
contribs: {
icon: icons.contribs,
label: i18n.t("statcard.contribs"),
value: contributedTo,
id: "contribs",
},
const STATS = {};
STATS.stars = {
icon: icons.star,
label: i18n.t("statcard.totalstars"),
value: totalStars,
id: "stars",
};
STATS.commits = {
icon: icons.commits,
label: `${i18n.t("statcard.commits")}${
include_all_commits ? "" : ` (${new Date().getFullYear()})`
}`,
value: totalCommits,
id: "commits",
};
STATS.prs = {
icon: icons.prs,
label: i18n.t("statcard.prs"),
value: totalPRs,
id: "prs",
};
STATS.issues = {
icon: icons.issues,
label: i18n.t("statcard.issues"),
value: totalIssues,
id: "issues",
};
STATS.contribs = {
icon: icons.contribs,
label: i18n.t("statcard.contribs"),
value: contributedTo,
id: "contribs",
};
// Extra stats items.
if (show_total_reviews) {
STATS.reviews = {
icon: icons.reviews,
label: i18n.t("statcard.reviews"),
value: totalReviews,
id: "reviews",
};
}
const longLocales = [
"cn",
+1
View File
@@ -27,6 +27,7 @@ export type StatCardOptions = CommonOptions & {
ring_color: string;
text_bold: boolean;
rank_icon: RankIcon;
show_total_reviews: boolean;
};
export type RepoCardOptions = CommonOptions & {