mirror of
https://github.com/penpot/penpot.git
synced 2025-06-17 00:21:37 +02:00
✨ Add proper impl for retrieving num of editors
This commit is contained in:
parent
1c224609b9
commit
18c7890f65
1 changed files with 22 additions and 3 deletions
|
@ -139,9 +139,28 @@
|
||||||
:type :validation
|
:type :validation
|
||||||
:hint "invalid data provided for `get-customer` rpc call"))
|
:hint "invalid data provided for `get-customer` rpc call"))
|
||||||
|
|
||||||
|
(def sql:get-customer-slots
|
||||||
|
"WITH teams AS (
|
||||||
|
SELECT tpr.team_id AS id,
|
||||||
|
tpr.profile_id AS profile_id
|
||||||
|
FROM team_profile_rel AS tpr
|
||||||
|
WHERE tpr.is_owner IS true
|
||||||
|
AND tpr.profile_id = ?
|
||||||
|
), teams_with_slots AS (
|
||||||
|
SELECT tpr.team_id AS id,
|
||||||
|
count(*) AS total
|
||||||
|
FROM team_profile_rel AS tpr
|
||||||
|
WHERE tpr.team_id IN (SELECT id FROM teams)
|
||||||
|
AND tpr.can_edit IS true
|
||||||
|
GROUP BY 1
|
||||||
|
ORDER BY 2
|
||||||
|
)
|
||||||
|
SELECT max(total) AS total FROM teams_with_slots;")
|
||||||
|
|
||||||
(defn- get-customer-slots
|
(defn- get-customer-slots
|
||||||
[system]
|
[system profile-id]
|
||||||
1)
|
(let [result (db/exec-one! system [sql:get-customer-slots profile-id])]
|
||||||
|
(:total result)))
|
||||||
|
|
||||||
(defmethod exec-command "get-customer"
|
(defmethod exec-command "get-customer"
|
||||||
[params]
|
[params]
|
||||||
|
@ -151,7 +170,7 @@
|
||||||
{:id (get profile :id)
|
{:id (get profile :id)
|
||||||
:name (get profile :fullname)
|
:name (get profile :fullname)
|
||||||
:email (get profile :email)
|
:email (get profile :email)
|
||||||
:used-slots (get-customer-slots system)
|
:num-editors (get-customer-slots system id)
|
||||||
:subscription (get props :subscription)})))
|
:subscription (get props :subscription)})))
|
||||||
|
|
||||||
(def ^:private schema:customer-subscription
|
(def ^:private schema:customer-subscription
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue