From a0c08b48e58c5851b980557c7d931452f6211ed7 Mon Sep 17 00:00:00 2001 From: Martin Lees <drov0@users.noreply.github.com> Date: Tue, 22 Mar 2022 22:23:32 -0400 Subject: [PATCH] test --- hive/db/sql_scripts/hive_post_operations.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hive/db/sql_scripts/hive_post_operations.sql b/hive/db/sql_scripts/hive_post_operations.sql index 2a4a57042..1f6da1b99 100644 --- a/hive/db/sql_scripts/hive_post_operations.sql +++ b/hive/db/sql_scripts/hive_post_operations.sql @@ -86,7 +86,7 @@ ON CONFLICT DO NOTHING ; if _parent_author != '' THEN RETURN QUERY INSERT INTO hive_posts as hp - (parent_id, depth, _community_id, category_id, + (parent_id, depth, community_id, category_id, root_id, is_muted, is_valid, author_id, permlink_id, created_at, updated_at, sc_hot, sc_trend, active, payout_at, cashout_time, counter_deleted, block_num, block_num_created) SELECT php.id AS parent_id, php.depth + 1 AS depth, @@ -94,14 +94,14 @@ if _parent_author != '' THEN WHEN _block_num > _community_support_start_block THEN COALESCE(php.community_id, (select hc.id from hive_communities hc where hc.name = _parent_permlink)) ELSE NULL - END) AS _community_id, -- community id has to be decorated because it creates confusion between the column and the variable + END) AS community_id, COALESCE(php.category_id, (select hcg.id from hive_category_data hcg where hcg.category = _parent_permlink)) AS category_id, (CASE(php.root_id) WHEN 0 THEN php.id ELSE php.root_id END) AS root_id, (CASE - WHEN _community_id is not null and php.is_muted = false THEN + WHEN hp.community_id is not null and php.is_muted = false THEN is_user_allowed_to_post_to_community(community_id, author_id, true) ELSE php.is_muted END) AS is_muted, @@ -137,7 +137,7 @@ ELSE ; RETURN QUERY INSERT INTO hive_posts as hp - (parent_id, depth, _community_id, category_id, + (parent_id, depth, community_id, category_id, root_id, is_muted, is_valid, author_id, permlink_id, created_at, updated_at, sc_hot, sc_trend, active, payout_at, cashout_time, counter_deleted, block_num, block_num_created, @@ -147,12 +147,12 @@ ELSE WHEN _block_num > _community_support_start_block THEN (select hc.id FROM hive_communities hc WHERE hc.name = _parent_permlink) ELSE NULL - END) AS _community_id, -- community id has to be decorated because it creates confusion between the column and the variable + END) AS community_id, (SELECT hcg.id FROM hive_category_data hcg WHERE hcg.category = _parent_permlink) AS category_id, 0 as root_id, -- will use id as root one if no parent (CASE - WHEN _community_id is not null THEN - is_user_allowed_to_post_to_community(_community_id, author_id, false) + WHEN hp.community_id is not null THEN + is_user_allowed_to_post_to_community(hp.community_id, author_id, false) ELSE false END) AS is_muted, true AS is_valid, ha.id AS author_id, hpd.id AS permlink_id, _date AS created_at, -- GitLab