From 6d1242e6e6ca7813f2cc4a488420831b25cb0103 Mon Sep 17 00:00:00 2001 From: Dariusz Kedzierski <dkedzierski@syncad.com> Date: Mon, 29 Jun 2020 14:18:50 +0200 Subject: [PATCH] Fixes for tags - process_hive_post_operation will return post_category, - post_category will be used to set initial post tag, - post_category a parent category if parent_author exists or parent_permlingif parent_author does not exists. --- hive/db/schema.py | 6 +++--- hive/indexer/posts.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hive/db/schema.py b/hive/db/schema.py index b93b997c8..6a3e29a68 100644 --- a/hive/db/schema.py +++ b/hive/db/schema.py @@ -421,7 +421,7 @@ def setup(db): in _date hive_posts.created_at%TYPE, in _community_support_start_date hive_posts.created_at%TYPE) RETURNS TABLE (id hive_posts.id%TYPE, author_id hive_posts.author_id%TYPE, permlink_id hive_posts.permlink_id%TYPE, - parent_id hive_posts.parent_id%TYPE, community_id hive_posts.community_id%TYPE, + post_category hive_category_data.category%TYPE, parent_id hive_posts.parent_id%TYPE, community_id hive_posts.community_id%TYPE, is_valid hive_posts.is_valid%TYPE, is_muted hive_posts.is_muted%TYPE, depth hive_posts.depth%TYPE, is_edited boolean) LANGUAGE plpgsql @@ -482,7 +482,7 @@ def setup(db): END ) - RETURNING hp.id, hp.author_id, hp.permlink_id, hp.parent_id, hp.community_id, hp.is_valid, hp.is_muted, hp.depth, (hp.updated_at > hp.created_at) as is_edited + RETURNING hp.id, hp.author_id, hp.permlink_id, (SELECT hcd.category FROM hive_category_data hcd WHERE hcd.id = hp.category_id) as post_category, hp.parent_id, hp.community_id, hp.is_valid, hp.is_muted, hp.depth, (hp.updated_at > hp.created_at) as is_edited ; ELSE INSERT INTO hive_category_data @@ -530,7 +530,7 @@ def setup(db): END ) - RETURNING hp.id, hp.author_id, hp.permlink_id, hp.parent_id, hp.community_id, hp.is_valid, hp.is_muted, hp.depth, (hp.updated_at > hp.created_at) as is_edited + RETURNING hp.id, hp.author_id, hp.permlink_id, _parent_permlink as post_category, hp.parent_id, hp.community_id, hp.is_valid, hp.is_muted, hp.depth, (hp.updated_at > hp.created_at) as is_edited ; END IF; END diff --git a/hive/indexer/posts.py b/hive/indexer/posts.py index db0823db6..cb49facc6 100644 --- a/hive/indexer/posts.py +++ b/hive/indexer/posts.py @@ -94,7 +94,7 @@ class Posts: """Register new/edited/undeleted posts; insert into feed cache.""" sql = """ - SELECT id, author_id, permlink_id, parent_id, community_id, is_valid, is_muted, depth, is_edited + SELECT id, author_id, permlink_id, post_category, parent_id, community_id, is_valid, is_muted, depth, is_edited FROM process_hive_post_operation((:author)::varchar, (:permlink)::varchar, (:parent_author)::varchar, (:parent_permlink)::varchar, (:date)::timestamp, (:community_support_start_date)::timestamp); """ @@ -124,7 +124,7 @@ class Posts: except Exception: pass - tags = [op['parent_permlink']] + tags = [result['post_category']] if md and 'tags' in md and isinstance(md['tags'], list): tags = tags + md['tags'] tags = map(lambda tag: (str(tag) or '').strip('# ').lower()[:32], tags) -- GitLab