From 6265c390aee033f3304eac656eba0d458f220e4f Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 1 Aug 2016 14:52:21 -0400 Subject: [PATCH] more list views. add user-id checking to recently added/changed views --- src/mtgcoll/views/core.clj | 4 +++- src/mtgcoll/views/functions/lists.clj | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/mtgcoll/views/core.clj b/src/mtgcoll/views/core.clj index eb4d092..c1d299b 100644 --- a/src/mtgcoll/views/core.clj +++ b/src/mtgcoll/views/core.clj @@ -41,7 +41,9 @@ (view :pricing-sources get-db #'prices/pricing-sources) (view :list-info get-db #'lists/list-info {:result-set-fn first}) + (view :list-settings get-db #'lists/list-settings {:result-set-fn first}) (view :lists-list get-db #'lists/lists-list) + (view :lists-basic-list get-db #'lists/lists-basic-list) (view :stats/owned-total get-db #'statistics/owned-total {:row-fn :total :result-set-fn first}) (view :stats/owned-foil-total get-db #'statistics/owned-foil-total {:row-fn :total :result-set-fn first}) @@ -76,7 +78,7 @@ :stats/total-sets-owned-all-from :stats/most-owned-sets :stats/most-copies-of-card :stats/most-nonland-copies-of-card :stats/total-price :stats/agg-price-stats :stats/most-valuable-cards :stats/num-cards-worth-over-1-dollar :stats/card-rarity-totals :full-card-info - :list-info :lists-list) + :list-info :list-settings :lists-list :lists-basic-list :card-inventory :total-card-inventory) (= username (last parameters)) ; views where the user-id parameter is second diff --git a/src/mtgcoll/views/functions/lists.clj b/src/mtgcoll/views/functions/lists.clj index bda0086..da38d74 100644 --- a/src/mtgcoll/views/functions/lists.clj +++ b/src/mtgcoll/views/functions/lists.clj @@ -10,6 +10,16 @@ and is_public in (true, ?)" list-id public-only?])) +(defn list-settings + [list-id user-id] + (let [list-id (int list-id) + public-only? (nil? user-id)] + ["select is_public, require_qualities + from lists + where id = ? + and is_public in (true, ?)" + list-id public-only?])) + (defn lists-list [user-id] (let [public-only? (nil? user-id)] @@ -19,3 +29,13 @@ and is_public in (true, ?) order by name" public-only?])) + +(defn lists-basic-list + [user-id] + (let [public-only? (nil? user-id)] + ["select id, name + from lists + where id != 0 + and is_public in (true, ?) + order by name" + public-only?]))