Skip to content
Snippets Groups Projects
Commit 082b7146 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'bw_sync_fixes' into 'develop'

hive sync fixes

See merge request !342
parents 0c0daad7 0ae18d45
Branches
Tags
2 merge requests!456Release candidate v1 24,!342hive sync fixes
......@@ -67,17 +67,18 @@ CREATE OR REPLACE FUNCTION public.update_all_hive_posts_children_count()
LANGUAGE 'plpgsql'
VOLATILE
AS $BODY$
declare __depth int;
declare __depth INT;
BEGIN
SELECT MAX(hp.depth) into __depth FROM hive_posts hp ;
DROP TABLE if exists __post_children;
create unlogged table __post_children
CREATE UNLOGGED TABLE IF NOT EXISTS __post_children
(
id int not null,
child_count int not null,
CONSTRAINT __post_children2_pkey PRIMARY KEY (id)
id INT NOT NULL,
child_count INT NOT NULL,
CONSTRAINT __post_children_pkey PRIMARY KEY (id)
);
TRUNCATE TABLE __post_children;
WHILE __depth >= 0 LOOP
INSERT INTO __post_children
......@@ -92,7 +93,7 @@ BEGIN
WHERE (h1.parent_id != 0 OR __depth = 0) AND h1.counter_deleted = 0 AND h1.id != 0 AND h1.depth = __depth
GROUP BY h1.parent_id
ON CONFLICT ON CONSTRAINT __post_children2_pkey DO UPDATE
ON CONFLICT ON CONSTRAINT __post_children_pkey DO UPDATE
SET child_count = __post_children.child_count + excluded.child_count
;
......
......@@ -277,7 +277,7 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.blacklisted = false
blacklisted = false
FROM
(
SELECT
......@@ -298,7 +298,7 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.state = 0
state = 0
FROM
(
SELECT
......@@ -320,7 +320,7 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.state = 0
state = 0
FROM
(
SELECT
......@@ -342,7 +342,7 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.follow_blacklists = false
follow_blacklists = false
FROM
(
SELECT
......@@ -383,7 +383,7 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.follow_muted = false
follow_muted = false
FROM
(
SELECT
......@@ -401,7 +401,7 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.follow_muted = true
follow_muted = true
FROM
(
SELECT
......@@ -423,10 +423,10 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.blacklisted = false,
hf.follow_blacklists = false,
hf.follow_muted = false,
hf.state = 0
blacklisted = false,
follow_blacklists = false,
follow_muted = false,
state = 0
FROM
(
SELECT
......@@ -444,8 +444,8 @@ class Follow(DbAdapterHolder):
UPDATE
hive_follows hf
SET
hf.follow_blacklists = true,
hf.follow_muted = true
follow_blacklists = true,
follow_muted = true
FROM
(
SELECT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment