about summary refs log tree commit diff
path: root/users/grfn/bbbg
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2021-12-26T18·11-0500
committerclbot <clbot@tvl.fyi>2021-12-26T18·16+0000
commit2dd74d6980788aeb2220930ad3322a6212037b35 (patch)
treeeff044e901b3ee41b18357857317ad84eac3d3ee /users/grfn/bbbg
parente8087acc7d42c2e275825ceffd04554aff5b9708 (diff)
feat(grfn/bbbg): Display attendee list on event page r/3438
Change-Id: I16caecf3b6edcabec05490e0d29780d45ecd1f91
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4673
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
Diffstat (limited to 'users/grfn/bbbg')
-rw-r--r--users/grfn/bbbg/src/bbbg/db/attendee.clj1
-rw-r--r--users/grfn/bbbg/src/bbbg/handlers/events.clj57
2 files changed, 53 insertions, 5 deletions
diff --git a/users/grfn/bbbg/src/bbbg/db/attendee.clj b/users/grfn/bbbg/src/bbbg/db/attendee.clj
index 91e13e07f860..58295642787c 100644
--- a/users/grfn/bbbg/src/bbbg/db/attendee.clj
+++ b/users/grfn/bbbg/src/bbbg/db/attendee.clj
@@ -31,6 +31,7 @@
    (if (db/database? db-or-query)
      (db/list db-or-query (for-event event-id))
      (-> db-or-query
+         (merge-select :event-attendee.*)
          (merge-join :event_attendee [:= :attendee.id :event_attendee.attendee_id])
          (merge-where [:= :event_attendee.event_id event-id]))))
   ([db query event-id]
diff --git a/users/grfn/bbbg/src/bbbg/handlers/events.clj b/users/grfn/bbbg/src/bbbg/handlers/events.clj
index 30bbf414a456..a5c9bdd5d65a 100644
--- a/users/grfn/bbbg/src/bbbg/handlers/events.clj
+++ b/users/grfn/bbbg/src/bbbg/handlers/events.clj
@@ -1,6 +1,7 @@
 (ns bbbg.handlers.events
   (:require
    [bbbg.db :as db]
+   [bbbg.db.attendee :as db.attendee]
    [bbbg.db.event :as db.event]
    [bbbg.event :as event]
    [bbbg.handlers.core :refer [*authenticated?* page-response]]
@@ -11,7 +12,12 @@
    [compojure.coercions :refer [as-uuid]]
    [compojure.core :refer [context GET POST]]
    [java-time :refer [local-date]]
-   [ring.util.response :refer [not-found redirect]])
+   [ring.util.response :refer [not-found redirect]]
+   [bbbg.attendee :as attendee]
+   [bbbg.event-attendee :as event-attendee]
+   [bbbg.db.attendee-check :as db.attendee-check]
+   [bbbg.attendee-check :as attendee-check]
+   [bbbg.user :as user])
   (:import
    java.time.format.FormatStyle))
 
@@ -78,7 +84,7 @@
     [:input {:type :submit
              :value "Import"}]]])
 
-(defn event-page [{:keys [event]}]
+(defn event-page [{:keys [event attendees]}]
   [:div.page
    [:div.page-header
     [:h1 (format-date (::event/date event)
@@ -89,7 +95,44 @@
     [:p (pluralize (:num-rsvps event) "RSVP")]
     [:p (num-attendees event)]]
    [:div
-    (import-attendees-form event)]])
+    (import-attendees-form event)]
+   [:div
+    [:table.attendees
+     [:thead
+      [:th "Meetup Name"]
+      [:th "Discord Name"]
+      [:th "Signed In"]
+      [:th "Last Vaccination Check"]
+      [:th "Notes"]]
+     [:tbody
+      (for [attendee attendees]
+        [:tr
+         [:td.attendee-name (::attendee/meetup-name attendee)]
+         [:td
+          [:label.mobile-label "Discord Name: "]
+          (or (not-empty (::attendee/discord-name attendee))
+              "—")]
+         [:td
+          [:label.mobile-label "Signed In: "]
+          (if (::event-attendee/attended? attendee)
+            [:span {:title "Yes"} "✔️"]
+            [:span {:title "No"} "❌"])]
+         [:td
+          [:label.mobile-label "Last Vaccination Check: "]
+          (if-let [last-check (:last-check attendee)]
+            (str "✔️ "(-> last-check
+                         ::attendee-check/checked-at
+                         format-date)
+                 ", by "
+                 (get-in last-check [:user ::user/username]))
+            (list
+             [:span {:title "Not Checked"}
+              "❌"]
+             " "
+             [:a {:href (str "/attendees/"
+                             (::attendee/id attendee)
+                             "/checks/edit")}
+              "Edit"]))]])]]]])
 
 (defn import-attendees-page [{:keys [event]}]
   [:div.page
@@ -160,8 +203,12 @@
                                       :from [:event]
                                       :where [:= :event.id id]}
                                      (db.event/with-stats)))]
-          (page-response
-           (event-page {:event event}))
+          (let [attendees (db.attendee-check/attendees-with-last-checks
+                           db
+                           (db/list db (db.attendee/for-event id)))]
+            (page-response
+             (event-page {:event event
+                          :attendees attendees})))
           (not-found "Event Not Found")))
 
       (GET "/attendees/import" []