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 917308d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/oph/heratepalvelu/tep/kestojenUudelleenlaskentaHandler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@
[_ 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 (:items resp)) "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)))))
(let [jakso-key (nh/ids jakso)]
(if-let [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 917308d

Please sign in to comment.