diff --git a/hive/db/schema.py b/hive/db/schema.py index b93b997c8260b3ddfca30d39daf08f094161a5cb..6a3e29a681b524145edd1b0f49ceebeb89473c27 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 db0823db698fa602799246c7d2177611b871a34e..cb49facc6870ba0802414587bf51868d9233625b 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)