From 2a680bb69b3f82ca280a1962b1d372dd7aa32ff1 Mon Sep 17 00:00:00 2001 From: frank-zsy Date: Fri, 6 Dec 2024 22:13:57 +0800 Subject: [PATCH] feat: add org and repo stats for label stat Signed-off-by: frank-zsy --- src/scripts/label_stats.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scripts/label_stats.ts b/src/scripts/label_stats.ts index 45389070..4a702404 100644 --- a/src/scripts/label_stats.ts +++ b/src/scripts/label_stats.ts @@ -17,10 +17,11 @@ import { getLabelData, getPlatformData } from "../label_data_utils"; } } - const labelPlatform = getPlatformData(['Region-0', 'Company', 'Community', 'Project', 'Foundation', 'Tech-0', 'Domain-0', 'Bot']); - const repoCount = await query(`SELECT COUNT(DISTINCT repo_id) FROM events WHERE ${labelPlatform.map(p => + const labelPlatform = getPlatformData(labels.map(l => l.identifier)); + const count = await query(`SELECT COUNT(DISTINCT org_id), COUNT(DISTINCT repo_id) FROM events WHERE ${labelPlatform.map(p => `(((repo_id IN (${p.repos.map(r => r.id).join(',')})) OR (org_id IN (${p.orgs.map(r => r.id).join(',')}))) AND platform='${p.name}')` ).join(' OR ')}`); - console.table(`Repos covered by labels: ${repoCount[0][0]}`); + console.table(`Orgs covered by labels: ${count[0][0]}`); + console.table(`Repos covered by labels: ${count[0][1]}`); })();