Commit ca55ed2

Andrew J.Swan <ajs.blackhole@gmail.com>
2024-02-28 09:46:04
Delorean the list of commits has been increased (#58)
* Delorean - The list of commits has been increased * Delorean - The list of commits has been increased (typo) * Delorean - The list of commits has been increased (fix) * Delorean - The list of commits has been increased (latests) * Delorean - The list of commits has been increased (prettier)
1 parent edff4ed
Changed files (1)
src
all-badges
delorean
src/all-badges/delorean/delorean.ts
@@ -1,20 +1,32 @@
 import { BadgePresenter, Present } from '../../badges.js'
+import { Commit } from '../../collect/collect.js'
 
 export default new (class implements BadgePresenter {
   url = new URL(import.meta.url)
   badges = ['delorean'] as const
   present: Present = (data, grant) => {
+    const commits: Commit[] = []
+
     for (const repo of data.repos) {
       for (const commit of repo.commits) {
         const data = new Date(commit.committedDate)
         if (data.getMonth() === 10 && data.getDate() === 5) {
-          grant(
-            'delorean',
-            'I committed on the day Doctor Emmett Brown invented the flux capacitor!',
-          ).evidenceCommits(commit)
-          return
+          commits.push(commit)
         }
       }
     }
+
+    if (commits.length > 0) {
+      grant(
+        'delorean',
+        'I committed on the day Doctor Emmett Brown invented the flux capacitor!',
+      ).evidenceCommits(...commits.sort(latest).slice(0, 6))
+    }
   }
 })()
+
+function latest(a: Commit, b: Commit) {
+  return (
+    new Date(b.committedDate).getTime() - new Date(a.committedDate).getTime()
+  )
+}