mirror of
https://github.com/penpot/penpot.git
synced 2025-03-19 19:21:23 -05:00
⚡ Add performance enhancements on telemetry related queries
This commit is contained in:
parent
0e92bcc0de
commit
ba167f256b
3 changed files with 20 additions and 9 deletions
backend/src/app
|
@ -391,7 +391,10 @@
|
|||
:fn (mg/resource "app/migrations/sql/0122-mod-file-data-fragment-table.sql")}
|
||||
|
||||
{:name "0123-mod-file-change-table"
|
||||
:fn (mg/resource "app/migrations/sql/0123-mod-file-change-table.sql")}])
|
||||
:fn (mg/resource "app/migrations/sql/0123-mod-file-change-table.sql")}
|
||||
|
||||
{:name "0124-mod-profile-table"
|
||||
:fn (mg/resource "app/migrations/sql/0124-mod-profile-table.sql")}])
|
||||
|
||||
(defn apply-migrations!
|
||||
[pool name migrations]
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
CREATE INDEX profile__props__newsletter1__idx ON profile (email) WHERE props->>'~:newsletter-news' = 'true';
|
||||
CREATE INDEX profile__props__newsletter2__idx ON profile (email) WHERE props->>'~:newsletter-updates' = 'true';
|
|
@ -62,19 +62,25 @@
|
|||
[conn]
|
||||
(-> (db/exec-one! conn ["SELECT count(*) AS count FROM file"]) :count))
|
||||
|
||||
(def ^:private sql:num-file-changes
|
||||
"SELECT count(*) AS count
|
||||
FROM file_change
|
||||
WHERE created_at < date_trunc('day', now()) + '24 hours'::interval
|
||||
AND created_at > date_trunc('day', now())")
|
||||
|
||||
(defn- get-num-file-changes
|
||||
[conn]
|
||||
(let [sql (str "SELECT count(*) AS count "
|
||||
" FROM file_change "
|
||||
" where date_trunc('day', created_at) = date_trunc('day', now())")]
|
||||
(-> (db/exec-one! conn [sql]) :count)))
|
||||
(-> (db/exec-one! conn [sql:num-file-changes]) :count))
|
||||
|
||||
(def ^:private sql:num-touched-files
|
||||
"SELECT count(distinct file_id) AS count
|
||||
FROM file_change
|
||||
WHERE created_at < date_trunc('day', now()) + '24 hours'::interval
|
||||
AND created_at > date_trunc('day', now())")
|
||||
|
||||
(defn- get-num-touched-files
|
||||
[conn]
|
||||
(let [sql (str "SELECT count(distinct file_id) AS count "
|
||||
" FROM file_change "
|
||||
" where date_trunc('day', created_at) = date_trunc('day', now())")]
|
||||
(-> (db/exec-one! conn [sql]) :count)))
|
||||
(-> (db/exec-one! conn [sql:num-touched-files]) :count))
|
||||
|
||||
(defn- get-num-users
|
||||
[conn]
|
||||
|
|
Loading…
Add table
Reference in a new issue