Stats card: show started and answered discussions stats (#2849)

* Stats card: show started and answered discussions stats

* trans

* dev
This commit is contained in:
Alexandr Garbuzov
2023-06-19 06:51:58 +03:00
committed by GitHub
parent a5260cb38a
commit 92518e375f
9 changed files with 137 additions and 7 deletions
+20
View File
@@ -86,6 +86,8 @@ const renderStatsCard = (stats = {}, options = {}) => {
totalIssues,
totalPRs,
totalReviews,
totalDiscussionsStarted,
totalDiscussionsAnswered,
contributedTo,
rank,
} = stats;
@@ -176,6 +178,24 @@ const renderStatsCard = (stats = {}, options = {}) => {
value: totalIssues,
id: "issues",
};
if (show.includes("discussions_started")) {
STATS.discussions_started = {
icon: icons.discussions_started,
label: i18n.t("statcard.discussions-started"),
value: totalDiscussionsStarted,
id: "discussions_started",
};
}
if (show.includes("discussions_answered")) {
STATS.discussions_answered = {
icon: icons.discussions_answered,
label: i18n.t("statcard.discussions-answered"),
value: totalDiscussionsAnswered,
id: "discussions_answered",
};
}
STATS.contribs = {
icon: icons.contribs,
label: i18n.t("statcard.contribs"),
+2
View File
@@ -7,6 +7,8 @@ const icons = {
contribs: `<path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"/>`,
fork: `<path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path>`,
reviews: `<path fill-rule="evenodd" d="M8 2c1.981 0 3.671.992 4.933 2.078 1.27 1.091 2.187 2.345 2.637 3.023a1.62 1.62 0 0 1 0 1.798c-.45.678-1.367 1.932-2.637 3.023C11.67 13.008 9.981 14 8 14c-1.981 0-3.671-.992-4.933-2.078C1.797 10.83.88 9.576.43 8.898a1.62 1.62 0 0 1 0-1.798c.45-.677 1.367-1.931 2.637-3.022C4.33 2.992 6.019 2 8 2ZM1.679 7.932a.12.12 0 0 0 0 .136c.411.622 1.241 1.75 2.366 2.717C5.176 11.758 6.527 12.5 8 12.5c1.473 0 2.825-.742 3.955-1.715 1.124-.967 1.954-2.096 2.366-2.717a.12.12 0 0 0 0-.136c-.412-.621-1.242-1.75-2.366-2.717C10.824 4.242 9.473 3.5 8 3.5c-1.473 0-2.825.742-3.955 1.715-1.124.967-1.954 2.096-2.366 2.717ZM8 10a2 2 0 1 1-.001-3.999A2 2 0 0 1 8 10Z"/>`,
discussions_started: `<path fill-rule="evenodd" d="M1.75 1h8.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 10.25 10H7.061l-2.574 2.573A1.458 1.458 0 0 1 2 11.543V10h-.25A1.75 1.75 0 0 1 0 8.25v-5.5C0 1.784.784 1 1.75 1ZM1.5 2.75v5.5c0 .138.112.25.25.25h1a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h3.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25Zm13 2a.25.25 0 0 0-.25-.25h-.5a.75.75 0 0 1 0-1.5h.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 14.25 12H14v1.543a1.458 1.458 0 0 1-2.487 1.03L9.22 12.28a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l2.22 2.22v-2.19a.75.75 0 0 1 .75-.75h1a.25.25 0 0 0 .25-.25Z" />`,
discussions_answered: `<path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z" />`,
};
/**
+10
View File
@@ -63,6 +63,12 @@ const GRAPHQL_STATS_QUERY = `
followers {
totalCount
}
repositoryDiscussions {
totalCount
}
repositoryDiscussionComments(onlyAnswers: true) {
totalCount
}
${GRAPHQL_REPOS_FIELD}
}
}
@@ -190,6 +196,8 @@ const fetchStats = async (
totalCommits: 0,
totalIssues: 0,
totalStars: 0,
totalDiscussionsStarted: 0,
totalDiscussionsAnswered: 0,
contributedTo: 0,
rank: { level: "C", percentile: 100 },
};
@@ -232,6 +240,8 @@ const fetchStats = async (
stats.totalReviews =
user.contributionsCollection.totalPullRequestReviewContributions;
stats.totalIssues = user.openIssues.totalCount + user.closedIssues.totalCount;
stats.totalDiscussionsStarted = user.repositoryDiscussions.totalCount;
stats.totalDiscussionsAnswered = user.repositoryDiscussionComments.totalCount;
stats.contributedTo = user.repositoriesContributedTo.totalCount;
// Retrieve stars while filtering out repositories to be hidden.
+2
View File
@@ -22,6 +22,8 @@ export type StatsData = {
totalCommits: number;
totalIssues: number;
totalStars: number;
totalDiscussionsStarted: number;
totalDiscussionsAnswered: number;
contributedTo: number;
rank: { level: string; percentile: number };
};
+60
View File
@@ -228,6 +228,66 @@ const statCardLocales = ({ name, apostrophe }) => {
vi: "Tổng Số PR Đã Xem Xét",
se: "Totalt antal granskade PR",
},
"statcard.discussions-started": {
ar: "مجموع بدء المناقشات",
cn: "发起的讨论总数",
"zh-tw": "發起的討論總數",
cs: "Celkem zahájených diskusí",
de: "Gesamt gestartete Diskussionen",
en: "Total Discussions Started",
bn: "সর্বমোট আলোচনা শুরু",
es: "Discusiones totales iniciadas",
fr: "Nombre total de discussions lancées",
hu: "Összes megkezdett megbeszélés",
it: "Discussioni totali avviate",
ja: "開始されたディスカッションの総数",
kr: "시작된 토론 총 수",
nl: "Totaal gestarte discussies",
"pt-pt": "Total de Discussões Iniciadas",
"pt-br": "Total de Discussões Iniciadas",
np: "कुल चर्चा सुरु",
el: "Σύνολο Συζητήσεων που Ξεκίνησαν",
ru: "Всего начатых дискуссий",
"uk-ua": "Всього розпочатих дискусій",
id: "Total Diskusi Dimulai",
my: "Jumlah Perbincangan Bermula",
sk: "Celkový počet začatých diskusií",
tr: "Başlatılan Toplam Tartışma",
pl: "Łącznie rozpoczętych dyskusji",
uz: "Boshlangan muzokaralar soni",
vi: "Tổng Số Thảo Luận Bắt Đầu",
se: "Totalt antal diskussioner startade",
},
"statcard.discussions-answered": {
ar: "مجموع الردود على المناقشات",
cn: "回复的讨论总数",
"zh-tw": "回覆的討論總數",
cs: "Celkem zodpovězených diskusí",
de: "Gesamt beantwortete Diskussionen",
en: "Total Discussions Answered",
bn: "সর্বমোট আলোচনা উত্তর",
es: "Discusiones totales respondidas",
fr: "Nombre total de discussions répondues",
hu: "Összes megválaszolt megbeszélés",
it: "Discussioni totali risposte",
ja: "回答されたディスカッションの総数",
kr: "답변된 토론 총 수",
nl: "Totaal beantwoorde discussies",
"pt-pt": "Total de Discussões Respondidas",
"pt-br": "Total de Discussões Respondidas",
np: "कुल चर्चा उत्तर",
el: "Σύνολο Συζητήσεων που Απαντήθηκαν",
ru: "Всего отвеченных дискуссий",
"uk-ua": "Всього відповідей на дискусії",
id: "Total Diskusi Dibalas",
my: "Jumlah Perbincangan Dijawab",
sk: "Celkový počet zodpovedaných diskusií",
tr: "Toplam Cevaplanan Tartışma",
pl: "Łącznie odpowiedzianych dyskusji",
uz: "Javob berilgan muzokaralar soni",
vi: "Tổng Số Thảo Luận Đã Trả Lời",
se: "Totalt antal diskussioner besvarade",
},
};
};