Skip to content

Commit 60538bc

Browse files
committed
fix: smarter fetch-current on frontend and backend
I can't believe this code exists in both places :/ We no longer assume there's only one :current true pomodoro in the database. might be easier to think of them as open vs closed, and include some metadata/process in 'closing' them out (e.g. stamping a doctor's report with commit and repos-pushed counts)
1 parent dc132c4 commit 60538bc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/api/pomodoros.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
(defn get-state []
1515
(let [current (some->> (db/query '[:find (pull ?e [*])
1616
:where [?e :pomodoro/is-current true]])
17-
ffirst)
17+
(map first)
18+
(sort-by :pomodoro/started-at dt/sort-latest-first)
19+
first)
1820
last (some->> (db/query '[:find (pull ?e [*])
1921
:where [?e :pomodoro/finished-at _]])
2022
(map first)

src/doctor/ui/db.cljs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@
117117
(let [current (some->>
118118
(d/q '[:find (pull ?e [*])
119119
:where [?e :pomodoro/is-current true]] conn)
120-
ffirst)
120+
(map first)
121+
;; ((fn [xs]
122+
;; (println "current pomodoros" xs)
123+
;; xs))
124+
(sort-by :pomodoro/started-at dt/sort-latest-first)
125+
first)
121126
last (some->>
122127
(d/q '[:find (pull ?e [*])
123128
:where [?e :pomodoro/finished-at _]] conn)

0 commit comments

Comments
 (0)