Add editors count to get-owned-teams rpc method response

This commit is contained in:
Andrey Antukh 2025-06-11 08:40:22 +02:00
parent f02dd9f8dc
commit 71f5806e23
2 changed files with 8 additions and 4 deletions

View file

@ -192,7 +192,8 @@
(def ^:private sql:get-owned-teams
"SELECT t.id, t.name,
(SELECT count(*) FROM team_profile_rel WHERE team_id=t.id) AS total_members
(SELECT count(*) FROM team_profile_rel WHERE team_id=t.id) AS total_members,
(SELECT count(*) FROM team_profile_rel WHERE team_id=t.id AND can_edit=true) AS total_editors
FROM team AS t
JOIN team_profile_rel AS tpr ON (tpr.team_id = t.id)
WHERE t.is_default IS false

View file

@ -460,11 +460,14 @@
::rpc/profile-id (:id profile1)}
out (th/command! params)]
;; (th/print-result! out)
(t/is (th/success? out))
(let [result (:result out)]
(let [[item1 :as result] (:result out)]
(t/is (= 1 (count result)))
(t/is (= (:id team1) (-> result first :id)))
(t/is (not= (:default-team-id profile1) (-> result first :id))))))
(t/is (= (:id team1) (:id item1)))
(t/is (= 1 (:total-members item1)))
(t/is (= 1 (:total-editors item1)))
(t/is (not= (:default-team-id profile1) (:id item1))))))
(t/deftest team-deletion-1