add creation date/times to lists

This commit is contained in:
Gered 2016-08-04 22:06:02 -04:00
parent 6c06ebb758
commit a23e780e0f
4 changed files with 10 additions and 5 deletions

View file

@ -0,0 +1 @@
ALTER TABLE lists DROP COLUMN IF EXISTS created_at;

View file

@ -0,0 +1 @@
ALTER TABLE lists ADD COLUMN created_at TIMESTAMP NOT NULL DEFAULT NOW();

View file

@ -9,7 +9,7 @@
[mtgcoll.common :as c] [mtgcoll.common :as c]
[mtgcoll.client.auth :as auth] [mtgcoll.client.auth :as auth]
[mtgcoll.client.page :refer [set-active-breadcrumb! set-error!]] [mtgcoll.client.page :refer [set-active-breadcrumb! set-error!]]
[mtgcoll.client.utils :refer [get-field-value]] [mtgcoll.client.utils :refer [get-field-value format-date]]
[mtgcoll.client.components.cards :refer [card-list-table ->card-list-pager]] [mtgcoll.client.components.cards :refer [card-list-table ->card-list-pager]]
[mtgcoll.client.components.search :as s] [mtgcoll.client.components.search :as s]
[mtgcoll.client.components.utils :refer [click-to-edit-textarea markdown confirm-modal]])) [mtgcoll.client.components.utils :refer [click-to-edit-textarea markdown confirm-modal]]))
@ -98,18 +98,20 @@
{:bordered true :striped true :condensed true :hover true} {:bordered true :striped true :condensed true :hover true}
[:thead [:thead
[:tr [:tr
[:th.col-sm-7 "Name"] [:th.col-sm-6 "Name"]
[:th.col-sm-3 "Card Qualities?"] [:th.col-sm-2 "Created At"]
[:th.col-sm-2 "Card Qualities?"]
[:th.col-sm-2 "Cards"]]] [:th.col-sm-2 "Cards"]]]
[:tbody [:tbody
(doall (doall
(map (map
(fn [{:keys [id name is_public require_qualities num_cards]}] (fn [{:keys [id name is_public require_qualities created_at num_cards]}]
^{:key id} ^{:key id}
[:tr [:tr
(if (and (auth/authenticated?) (not is_public)) (if (and (auth/authenticated?) (not is_public))
{:class "warning"}) {:class "warning"})
[:td [:a {:href (->url "#/list/" id)} [:div name]]] [:td [:a {:href (->url "#/list/" id)} [:div name]]]
[:td (format-date (new js/Date created_at))]
[:td (if require_qualities "Yes" "")] [:td (if require_qualities "Yes" "")]
[:td num_cards]]) [:td num_cards]])
@lists))]]))])))) @lists))]]))]))))

View file

@ -4,7 +4,7 @@
[list-id user-id] [list-id user-id]
(let [list-id (int list-id) (let [list-id (int list-id)
public-only? (nil? user-id)] public-only? (nil? user-id)]
["select name, notes, is_public, require_qualities ["select name, notes, is_public, require_qualities, created_at
from lists from lists
where id = ? where id = ?
and is_public in (true, ?)" and is_public in (true, ?)"
@ -27,6 +27,7 @@
l.name, l.name,
l.is_public, l.is_public,
l.require_qualities, l.require_qualities,
l.created_at,
( (
select coalesce(sum(lc.quantity), 0) select coalesce(sum(lc.quantity), 0)
from lists_card_quantities lc from lists_card_quantities lc