From 388bb3fb7d1e820a22474e8e77a7d7e8865150a6 Mon Sep 17 00:00:00 2001 From: Simon Brooke <simon@journeyman.cc> Date: Sun, 23 Sep 2018 13:27:56 +0100 Subject: [PATCH] Fixed the pin-image regression --- resources/public/error/502.html | 33 ++++++------------- resources/sql/queries.sql | 9 +++++ src/clj/youyesyet/routes/rest.clj | 2 +- src/cljs/youyesyet/canvasser_app/gis.cljs | 12 ++++--- .../youyesyet/canvasser_app/handlers.cljs | 3 +- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/resources/public/error/502.html b/resources/public/error/502.html index d0f149f..2118ede 100644 --- a/resources/public/error/502.html +++ b/resources/public/error/502.html @@ -26,29 +26,16 @@ </header> <div id="main-container" class="container"> - <div id="content"> - - <div class="container-fluid"> - <div class="row-fluid"> - <div class="col-lg-12"> - <div class="centering text-center"> - <div class="text-center"> - <h2><span class="text-danger">Error: 502 Bad Gateway</span></h2> - <p> - We are suffering an intermittent problem causing an occasional crash of - the Project Hope canvassing application. We apologise for this, and are - working on a permanent fix. - </p> - <p> - The application will restart automatically - within five minutes, please take a short break. - </p> - <hr> - </div> - </div> - </div> - </div> - </div> + <h2><span class="text-danger">Error: 502 Bad Gateway</span></h2> + <p> + We are suffering an intermittent problem causing an occasional crash of + the Project Hope canvassing application. We apologise for this, and are + working on a permanent fix. + </p> + <p> + The application will restart automatically + within five minutes, please take a short break. + </p> </div> <br clear="both"/> diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 855342f..017463e 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -85,3 +85,12 @@ WHERE roles.id = ln_canvassers_roles.role_id AND ln_canvassers_roles.canvasser_id = :id ORDER BY roles.name, roles.id + +-- :name list-elector-intentions :? :* +-- :doc short form of `list-intentions-by-elector`, returning far less data, +-- for use in `youyesyet.routes.rest/get-local-data`, q.v. +SELECT intentions.id, intentions.option_id, visits.date +FROM intentions, visits +WHERE intentions.visit_id = visits.id +AND intentions.elector_id = :id +ORDER BY visits.date DESC diff --git a/src/clj/youyesyet/routes/rest.clj b/src/clj/youyesyet/routes/rest.clj index cf6d85c..351926e 100644 --- a/src/clj/youyesyet/routes/rest.clj +++ b/src/clj/youyesyet/routes/rest.clj @@ -69,7 +69,7 @@ (fn [e] (assoc e :intentions - (db/list-intentions-by-elector db/*db* {:id (:id e)}))) + (db/list-elector-intentions db/*db* {:id (:id e)}))) (db/list-electors-by-dwelling db/*db* {:id (:id d)})))) (db/list-dwellings-by-address db/*db* {:id (:id a)})))) addresses))) diff --git a/src/cljs/youyesyet/canvasser_app/gis.cljs b/src/cljs/youyesyet/canvasser_app/gis.cljs index b580a3c..3dd3389 100644 --- a/src/cljs/youyesyet/canvasser_app/gis.cljs +++ b/src/cljs/youyesyet/canvasser_app/gis.cljs @@ -2,6 +2,7 @@ :author "Simon Brooke"} youyesyet.canvasser-app.gis (:require [cljs.reader :refer [read-string]] + [clojure.string :refer [lower-case]] [cemerick.url :refer (url url-encode)] [day8.re-frame.http-fx] [re-frame.core :refer [dispatch reg-event-db reg-event-fx subscribe]] @@ -66,13 +67,14 @@ (set (remove nil? - (map - :intention - (mapcat :electors - (:dwellings address)))))] + (map :option_id + (mapcat + :intentions + (mapcat :electors + (:dwellings address))))))] (case (count intentions) 0 "unknown-pin" - 1 (str (name (first intentions)) "-pin") + 1 (lower-case (str (name (first intentions)) "-pin")) "mixed-pin"))) diff --git a/src/cljs/youyesyet/canvasser_app/handlers.cljs b/src/cljs/youyesyet/canvasser_app/handlers.cljs index 0c2ec97..d857bc2 100644 --- a/src/cljs/youyesyet/canvasser_app/handlers.cljs +++ b/src/cljs/youyesyet/canvasser_app/handlers.cljs @@ -181,6 +181,7 @@ ;; TODO: why is this an `-fx`? Does it need to be? (fn [{db :db} [_ response]] + (js/console.log (str ":process-locality: " response)) (js/console.log (str "Updating locality data: " (count response) " addresses " )) (refresh-map-pins) {:db (assoc @@ -194,7 +195,7 @@ (fn [{db :db} [_ response]] ;; TODO: signal something has failed? It doesn't matter very much, unless it keeps failing. - (js/console.log "Failed to fetch locality data") + (js/console.log (str "Failed to fetch locality data" response)) ;; loop to do it again (dispatch [:dispatch-later [{:ms 60000 :dispatch [:fetch-locality]}]]) {:db (assoc