Commit cb80398

Anton Medvedev <anton@medv.io>
2023-10-14 22:39:13
Add the answer to the ultimate question of life, the universe, and everything
1 parent 6c0d3e7
Changed files (3)
src/all-badges/the-ultimate-question/the-ultimate-question.png
Binary file
src/all-badges/the-ultimate-question/the-ultimate-question.ts
@@ -0,0 +1,28 @@
+import { BadgePresenter, Present } from '../../badges.js'
+import { Issue, Pull } from '../../collect/collect.js'
+
+export default new (class implements BadgePresenter {
+  url = new URL(import.meta.url)
+  badges = ['the-ultimate-question'] as const
+  present: Present = (data, grant) => {
+    const list: (Issue | Pull)[] = []
+
+    for (const issue of data.issues) {
+      if (issue.number == 42) list.push(issue)
+    }
+    for (const pull of data.pulls) {
+      if (pull.number == 42) list.push(pull)
+    }
+
+    if (list.length > 0) {
+      grant(
+        'the-ultimate-question',
+        'I found the answer to the ultimate question of life, the universe, and everything!',
+      ).evidence(list.map((x) => `- ${link(x)}`).join('\n'))
+    }
+  }
+})()
+
+function link(x: Issue | Pull): string {
+  return `<a href="https://github.com/${x.repository.owner.login}/${x.repository.name}/issues/${x.number}">#${x.number}</a>`
+}
src/all-badges/index.ts
@@ -18,4 +18,5 @@ export const allBadges = [
   await import('./public-keys/public-keys.js'),
   await import('./old-issue/old-issue.js'),
   await import('./this-is-fine/this-is-fine.js'),
+  await import('./the-ultimate-question/the-ultimate-question.js'),
 ] as const