From 17d73f0a89bbd71577baba02414d018a8c341c5e Mon Sep 17 00:00:00 2001 From: Casey Link Date: Mon, 20 Nov 2023 20:18:05 +0100 Subject: [PATCH] add some logging to song sync --- src/clj/app/cms.clj | 20 ++++++++++---------- src/clj/app/jobs/gig_events.clj | 2 ++ src/clj/app/jobs/sync_songs.clj | 6 +++++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/clj/app/cms.clj b/src/clj/app/cms.clj index 3a3e482..4711377 100644 --- a/src/clj/app/cms.clj +++ b/src/clj/app/cms.clj @@ -1,5 +1,6 @@ (ns app.cms (:require + [clojure.tools.logging :as log] [app.errors :as errors] [jsonista.core :as j] [org.httpkit.client :as client] @@ -7,7 +8,6 @@ [datomic.client.api :as datomic] [tick.core :as t])) - (defn update-cms-req [cms-url token payload] {:method :post :url (str cms-url "/api/song/") @@ -26,15 +26,16 @@ :arrangement_notes arrangement-notes :last_played_date (when last-played-on (-> last-played-on t/date-time str))}) - (defn sync-song! [{:keys [db] :as system} song-id] (try - (let [ - {:keys [token cms-url]} (-> system :env :cms) - song (q/retrieve-song db song-id)] - @(client/request (->> song - song->wagtail - (update-cms-req cms-url token)))) + (let [{:keys [token cms-url]} (-> system :env :cms) + song (q/retrieve-song db song-id) + resp @(client/request (->> song + song->wagtail + (update-cms-req cms-url token)))] + (log/info (str "synced with cms song-id=" song-id)) + (log/info resp) + resp) (catch Exception e (errors/report-error! e)))) @@ -52,5 +53,4 @@ @(client/request req)))] resp) (catch Exception e - (errors/report-error! e)) - )) + (errors/report-error! e)))) diff --git a/src/clj/app/jobs/gig_events.clj b/src/clj/app/jobs/gig_events.clj index 0f58a3b..a674820 100644 --- a/src/clj/app/jobs/gig_events.clj +++ b/src/clj/app/jobs/gig_events.clj @@ -1,5 +1,6 @@ (ns app.jobs.gig-events (:require + [clojure.tools.logging :as log] [app.cms :as cms] [app.caldav :as caldav] [app.discourse :as discourse] @@ -72,6 +73,7 @@ (exec-later handle-gig-created req notify? thread? gig-id)) (defn handle-song-edited [req song-id] + (log/info (str "handle-song-edited song-id=" song-id)) (cms/sync-song! (update-system req) song-id)) (defn trigger-song-edited diff --git a/src/clj/app/jobs/sync_songs.clj b/src/clj/app/jobs/sync_songs.clj index 555aa00..b673c21 100644 --- a/src/clj/app/jobs/sync_songs.clj +++ b/src/clj/app/jobs/sync_songs.clj @@ -4,9 +4,13 @@ [datomic.client.api :as datomic] [ol.jobs-util :as jobs])) +(defn song-sync-job [system _] + (cms/sync-all-songs! system)) + (defn make-songs-sync-job [system] (fn [{:job/keys [frequency initial-delay]}] - (jobs/make-repeating-job (partial #'cms/sync-all-songs! system) frequency initial-delay))) + (jobs/make-repeating-job + (partial #'song-sync-job system) frequency initial-delay))) (comment