🔥 Remove unused code.

This commit is contained in:
Andrey Antukh 2020-01-14 15:29:36 +01:00
parent b441ffc20f
commit 422536d4a1
13 changed files with 61 additions and 51 deletions

View file

@ -28,7 +28,7 @@
;; --- Query: Collections
(def ^:private icons-collections-sql
(def sql:icons-collections
"select *,
(select count(*) from icons where collection_id = ic.id) as num_icons
from icon_collections as ic
@ -42,7 +42,7 @@
(sq/defquery ::icons-collections
[{:keys [user] :as params}]
(let [sqlv [icons-collections-sql user]]
(let [sqlv [sql:icons-collections user]]
(db/query db/pool sqlv)))
;; --- Icons By Collection ID

View file

@ -87,22 +87,22 @@
;; --- Query Images by Collection (id)
(su/defstr sql:images-by-collection
(def sql:images-by-collection
"select * from images
where (user_id = $1 or
user_id = '00000000-0000-0000-0000-000000000000'::uuid)
and deleted_at is null
order by created_at desc")
(su/defstr sql:images-by-collection1
"with images as (~{sql:images-by-collection})
select im.* from images as im
where im.collection_id is null")
(def sql:images-by-collection1
(str "with images as (" sql:images-by-collection ")
select im.* from images as im
where im.collection_id is null"))
(su/defstr sql:images-by-collection2
"with images as (~{sql:images-by-collection})
select im.* from images as im
where im.collection_id = $2")
(def sql:images-by-collection2
(str "with images as (" sql:images-by-collection ")
select im.* from images as im
where im.collection_id = $2"))
(s/def ::images-by-collection
(s/keys :req-un [::user]

View file

@ -2,12 +2,14 @@
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz>
;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2019-2020 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.services.queries.project-files
(:require
[clojure.spec.alpha :as s]
[cuerdas.core :as str]
[promesa.core :as p]
[uxbox.common.spec :as us]
[uxbox.db :as db]
@ -25,7 +27,7 @@
(s/def ::file-id ::us/uuid)
(s/def ::user ::us/uuid)
(su/defstr sql:generic-project-files
(def sql:generic-project-files
"select distinct on (pf.id, pf.created_at)
pf.*,
p.name as project_name,
@ -58,16 +60,16 @@
(retrieve-recent-files db/pool params)
(retrieve-project-files db/pool params)))
(su/defstr sql:project-files
"with files as (~{sql:generic-project-files})
select * from files where project_id = $2
order by created_at asc")
(def sql:project-files
(str "with files as (" sql:generic-project-files ")
select * from files where project_id = $2
order by created_at asc"))
(su/defstr sql:recent-files
"with files as (~{sql:generic-project-files})
select * from files
order by modified_at desc
limit $2")
(def sql:recent-files
(str "with files as (" sql:generic-project-files ")
select * from files
order by modified_at desc
limit $2"))
(defn retrieve-project-files
[conn {:keys [user project-id]}]
@ -82,9 +84,9 @@
;; --- Query: Project File (By ID)
(su/defstr sql:project-file
"with files as (~{sql:generic-project-files})
select * from files where id = $2")
(def sql:project-file
(str "with files as (" sql:generic-project-files ")
select * from files where id = $2"))
(s/def ::project-file
(s/keys :req-un [::user ::id]))
@ -97,7 +99,18 @@
;; --- Query: Users of the File
(su/defstr sql:file-users
(def sql:file-users
"select u.id, u.fullname, u.photo
from users as u
join project_file_users as pfu on (pfu.user_id = u.id)
where pfu.file_id = $1
union all
select u.id, u.fullname, u.photo
from users as u
join project_users as pu on (pu.user_id = u.id)
where pu.project_id = $2")
(def sql:file-users
"select u.id, u.fullname, u.photo
from users as u
join project_file_users as pfu on (pfu.user_id = u.id)
@ -110,9 +123,9 @@
(declare retrieve-minimal-file)
(su/defstr sql:minimal-file
"with files as (~{sql:generic-project-files})
select id, project_id from files where id = $2")
(def sql:minimal-file
(str "with files as (" sql:generic-project-files ")
select id, project_id from files where id = $2"))
(s/def ::project-file-users
(s/keys :req-un [::user ::file-id]))

View file

@ -24,7 +24,7 @@
(s/def ::project-id ::us/uuid)
(s/def ::file-id ::us/uuid)
(def ^:private sql:generic-project-pages
(def sql:generic-project-pages
"select pp.*
from project_pages as pp
inner join project_files as pf on (pf.id = pp.file_id)
@ -38,7 +38,7 @@
;; --- Query: Project Pages (By File ID)
(def ^:private sql:project-pages
(def sql:project-pages
(str "with pages as (" sql:generic-project-pages ")"
" select * from pages where file_id = $2"))

View file

@ -26,7 +26,7 @@
;; --- Query: Projects
(su/defstr sql:projects
(def sql:projects
"select p.*
from project_users as pu
inner join projects as p on (p.id = pu.project_id)