summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20200508092434_update_counter_cache_table.exs
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2020-05-09 11:30:37 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2020-05-09 11:30:37 +0300
commitcbe383ae832f13d5d2a20ee8fb5e85498205fbc3 (patch)
treef61d822df39cf74652508fb343a06662c44e660b /priv/repo/migrations/20200508092434_update_counter_cache_table.exs
parent39d2f2118aed7906cb352d8a37f22da73f3a3aa3 (diff)
downloadpleroma-cbe383ae832f13d5d2a20ee8fb5e85498205fbc3.tar.gz
pleroma-cbe383ae832f13d5d2a20ee8fb5e85498205fbc3.zip
Update stats admin endpoint
Diffstat (limited to 'priv/repo/migrations/20200508092434_update_counter_cache_table.exs')
-rw-r--r--priv/repo/migrations/20200508092434_update_counter_cache_table.exs8
1 files changed, 6 insertions, 2 deletions
diff --git a/priv/repo/migrations/20200508092434_update_counter_cache_table.exs b/priv/repo/migrations/20200508092434_update_counter_cache_table.exs
index 81a8d6397..3d9bfc877 100644
--- a/priv/repo/migrations/20200508092434_update_counter_cache_table.exs
+++ b/priv/repo/migrations/20200508092434_update_counter_cache_table.exs
@@ -43,7 +43,8 @@ defmodule Pleroma.Repo.Migrations.UpdateCounterCacheTable do
END IF;
IF TG_OP = 'INSERT' THEN
visibility_new := activity_visibility(NEW.actor, NEW.recipients, NEW.data);
- IF NEW.data->>'type' = 'Create' THEN
+ IF NEW.data->>'type' = 'Create'
+ AND visibility_new IN ('public', 'unlisted', 'private', 'direct') THEN
EXECUTE format('INSERT INTO "counter_cache" ("instance", %1$I) VALUES ($1, 1)
ON CONFLICT ("instance") DO
UPDATE SET %1$I = "counter_cache".%1$I + 1', visibility_new)
@@ -53,7 +54,10 @@ defmodule Pleroma.Repo.Migrations.UpdateCounterCacheTable do
ELSIF TG_OP = 'UPDATE' THEN
visibility_new := activity_visibility(NEW.actor, NEW.recipients, NEW.data);
visibility_old := activity_visibility(OLD.actor, OLD.recipients, OLD.data);
- IF (NEW.data->>'type' = 'Create') and (OLD.data->>'type' = 'Create') and visibility_new != visibility_old THEN
+ IF (NEW.data->>'type' = 'Create')
+ AND (OLD.data->>'type' = 'Create')
+ AND visibility_new != visibility_old
+ AND visibility_new IN ('public', 'unlisted', 'private', 'direct') THEN
EXECUTE format('UPDATE "counter_cache" SET
%1$I = greatest("counter_cache".%1$I - 1, 0),
%2$I = "counter_cache".%2$I + 1