about summary refs log tree commit diff
path: root/users/grfn
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2021-12-27T15·49-0500
committerclbot <clbot@tvl.fyi>2021-12-27T15·59+0000
commit7ce9277a8e9e91b477c072a457d84cabd0054850 (patch)
treececc5ca464f75c4cad759ab1e8942f940ad48721 /users/grfn
parentdf8edcb5f7543baac51bddcd65faaac1e69989ee (diff)
fix(grfn/bbbg): Allow importing empty attendee lists r/3475
Change-Id: I278c586db7a8641a9e254f05075ee4e8bdf78d67
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4715
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
Diffstat (limited to 'users/grfn')
-rw-r--r--users/grfn/bbbg/src/bbbg/db/attendee.clj21
-rw-r--r--users/grfn/bbbg/src/bbbg/db/event_attendee.clj19
2 files changed, 21 insertions, 19 deletions
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]}})))