From 7ce9277a8e9e91b477c072a457d84cabd0054850 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 27 Dec 2021 10:49:50 -0500 Subject: fix(grfn/bbbg): Allow importing empty attendee lists Change-Id: I278c586db7a8641a9e254f05075ee4e8bdf78d67 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4715 Tested-by: BuildkiteCI Reviewed-by: grfn Autosubmit: grfn --- users/grfn/bbbg/src/bbbg/db/attendee.clj | 21 +++++++++++---------- users/grfn/bbbg/src/bbbg/db/event_attendee.clj | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'users') diff --git a/users/grfn/bbbg/src/bbbg/db/attendee.clj b/users/grfn/bbbg/src/bbbg/db/attendee.clj index 58295642787c..da5ee29321fb 100644 --- a/users/grfn/bbbg/src/bbbg/db/attendee.clj +++ b/users/grfn/bbbg/src/bbbg/db/attendee.clj @@ -54,16 +54,17 @@ (defn upsert-all! [db attendees] - (db/list - db - {:insert-into :attendee - :values (map #(->> % - (db/process-key-map :attendee) - (u/map-keys keyword)) - attendees) - :upsert {:on-conflict [:meetup-user-id] - :do-update-set [:meetup-name]} - :returning [:id :meetup-user-id]})) + (when (seq attendees) + (db/list + db + {:insert-into :attendee + :values (map #(->> % + (db/process-key-map :attendee) + (u/map-keys keyword)) + attendees) + :upsert {:on-conflict [:meetup-user-id] + :do-update-set [:meetup-name]} + :returning [:id :meetup-user-id]}))) (comment (def db (:db bbbg.core/system)) diff --git a/users/grfn/bbbg/src/bbbg/db/event_attendee.clj b/users/grfn/bbbg/src/bbbg/db/event_attendee.clj index 9fa8ad47980d..31411e5d4504 100644 --- a/users/grfn/bbbg/src/bbbg/db/event_attendee.clj +++ b/users/grfn/bbbg/src/bbbg/db/event_attendee.clj @@ -5,12 +5,13 @@ (defn upsert-all! [db attendees] - (db/execute! - db - {:insert-into :event-attendee - :values (map #(->> % - (db/process-key-map :event-attendee) - (u/map-keys keyword)) - attendees) - :upsert {:on-conflict [:event-id :attendee-id] - :do-update-set [:rsvpd-attending]}})) + (when (seq attendees) + (db/execute! + db + {:insert-into :event-attendee + :values (map #(->> % + (db/process-key-map :event-attendee) + (u/map-keys keyword)) + attendees) + :upsert {:on-conflict [:event-id :attendee-id] + :do-update-set [:rsvpd-attending]}}))) -- cgit 1.4.1