github-reporadar 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.html CHANGED
@@ -16,7 +16,7 @@
16
16
  href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap"
17
17
  rel="stylesheet"
18
18
  />
19
- <script type="module" crossorigin src="/assets/index-Bb1rtvKk.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-LfkmcOcl.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-B5UAXuco.css">
21
21
  </head>
22
22
  <body>
package/dist-cli/cli.js CHANGED
@@ -245,6 +245,19 @@ async function listCommits(token, repo, since, author) {
245
245
  }
246
246
  return commits.filter((c) => c.author?.type !== "Bot");
247
247
  }
248
+ function parsePrMeta(prs) {
249
+ const out = /* @__PURE__ */ new Map();
250
+ for (const n of prs?.nodes ?? []) {
251
+ out.set(n.number, {
252
+ author: n.author?.login ?? null,
253
+ reviewers: n.reviewRequests.nodes.map((r) => r.requestedReviewer?.login).filter((l) => typeof l === "string"),
254
+ reviewDecision: n.reviewDecision ?? null,
255
+ isDraft: n.isDraft,
256
+ linkedIssues: (n.closingIssuesReferences?.nodes ?? []).map((x) => x.number)
257
+ });
258
+ }
259
+ return out;
260
+ }
248
261
  async function fetchOpenCounts(token, fullNames, limit) {
249
262
  const result = /* @__PURE__ */ new Map();
250
263
  const CHUNK = 25;
@@ -253,7 +266,7 @@ async function fetchOpenCounts(token, fullNames, limit) {
253
266
  await Promise.all(chunks.map((chunk) => limit(async () => {
254
267
  const fields = chunk.map((name, j) => {
255
268
  const [owner, repo] = name.split("/");
256
- return `r${j}: repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(repo)}) { issues(states: OPEN) { totalCount } pullRequests(states: OPEN) { totalCount } }`;
269
+ return `r${j}: repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(repo)}) { issues(states: OPEN) { totalCount } pullRequests(states: OPEN, first: 50) { totalCount nodes { number isDraft reviewDecision author { login } reviewRequests(first: 10) { nodes { requestedReviewer { ... on User { login } ... on Team { name } } } } closingIssuesReferences(first: 10) { nodes { number } } } } }`;
257
270
  }).join("\n");
258
271
  const res = await fetch(`${API}/graphql`, {
259
272
  method: "POST",
@@ -268,7 +281,8 @@ ${fields}
268
281
  const node = json.data?.[`r${j}`];
269
282
  result.set(name, {
270
283
  pr: node?.pullRequests.totalCount ?? 0,
271
- issue: node?.issues.totalCount ?? 0
284
+ issue: node?.issues.totalCount ?? 0,
285
+ prMeta: parsePrMeta(node?.pullRequests)
272
286
  });
273
287
  });
274
288
  })));
@@ -306,7 +320,8 @@ async function listOpenIssues(token, repo, login) {
306
320
  labels: it.labels.map((l) => l.name),
307
321
  updatedAt: it.updated_at,
308
322
  url: it.html_url,
309
- comments: it.comments
323
+ comments: it.comments,
324
+ author: it.user?.login ?? null
310
325
  });
311
326
  }
312
327
  url = result.next;
@@ -396,7 +411,11 @@ async function fetchActivity(token, from, opts) {
396
411
  }))
397
412
  });
398
413
  });
399
- const issues = issuesByRepo.flat();
414
+ const issues = issuesByRepo.flat().map((it) => {
415
+ if (it.type !== "pr") return it;
416
+ const meta = openCounts.get(it.repo)?.prMeta.get(it.number);
417
+ return meta ? { ...it, ...meta } : it;
418
+ });
400
419
  return { login, repos, activity, issues };
401
420
  }
402
421
  const REPO_CACHE_DIR = join(import.meta.dirname, "..", "public", "data");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-reporadar",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "自分のGitHub活動を一晩ぶん眺める計器盤。npx github-reporadarでローカルに開く",
5
5
  "license": "MIT",
6
6
  "bin": {