show list card total in lists table and whether qualities are tracked

This commit is contained in:
Gered 2016-08-01 16:00:18 -04:00
parent 2cc0c65f0e
commit e4c2a03b72
2 changed files with 19 additions and 9 deletions

View file

@ -98,18 +98,20 @@
{:bordered true :striped true :condensed true :hover true}
[:thead
[:tr
[:th "Name"]
[:th "Cards"]]]
[:th.col-sm-7 "Name"]
[:th.col-sm-3 "Card Qualities?"]
[:th.col-sm-2 "Cards"]]]
[:tbody
(doall
(map
(fn [{:keys [id name is_public]}]
(fn [{:keys [id name is_public require_qualities num_cards]}]
^{:key id}
[:tr
(if (and (auth/authenticated?) (not is_public))
{:class "warning"})
[:td [:a {:href (->url "#/list/" id)} [:div name]]]
[:td "--"]])
[:td (if require_qualities "Yes" "")]
[:td num_cards]])
@lists))]]))]))))
(defn on-update-list-notes!

View file

@ -23,11 +23,19 @@
(defn lists-list
[user-id]
(let [public-only? (nil? user-id)]
["select id, name, is_public, require_qualities
from lists
where id != 0
and is_public in (true, ?)
order by name"
["select l.id,
l.name,
l.is_public,
l.require_qualities,
(
select coalesce(sum(lc.quantity), 0)
from lists_card_quantities lc
where lc.list_id = l.id
) as num_cards
from lists l
where l.id != 0
and l.is_public in (true, ?)
order by l.name"
public-only?]))
(defn lists-basic-list