Skip to content

Commit

Permalink
EH-1698: add logging for more transparency in kestojen uudelleenlaskenta
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalliok committed Sep 16, 2024
1 parent d2d0353 commit 269bfe7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/oph/heratepalvelu/tep/kestojenUudelleenlaskentaHandler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@
[_ event ^com.amazonaws.services.lambda.runtime.Context context]
(log-caller-details-scheduled "handleKestojenUudelleenlaskenta" event context)
(loop [resp (scan-for-jaksot-with-kesto! nil)]
(log/info "Processing" (count jaksot) "jaksoa.")
(let [jaksot (:items resp)
kestot (nh/jaksojen-kestot! jaksot)]
(log/info "Got" (count kestot) "durations for jaksot:"
(clojure.string/join ", " (take 3 (keys kestot))) ", ...")
(doseq [jakso jaksot]
(if-let [new-kesto (get kestot (nh/ids jakso))]
(tc/update-jakso jakso
{:kesto [:n new-kesto]
:kesto_vanha [:n (:kesto jakso)]})
(log/warn "Couldn't calculate kesto for jakso with ids "
(nh/ids jakso)))))
(if-let [jakso-key (nh/ids jakso)
new-kesto (get kestot jakso-key)]
(do
(log/info "Updating jakso" jakso-key "with kesto" new-kesto)
(tc/update-jakso jakso
{:kesto [:n new-kesto]
:kesto_vanha [:n (:kesto jakso)]}))
(log/warn "Couldn't calculate kesto for jakso with ids" jakso-key))))
(when (and (< 30000 (.getRemainingTimeInMillis context))
(:last-evaluated-key resp))
(recur (scan-for-jaksot-with-kesto! (:last-evaluated-key resp))))))

0 comments on commit 269bfe7

Please sign in to comment.