diff --git a/README.md b/README.md index 459768fd3eb8861c3ee24954eedc02d3c6af252e..837faa0e799693cf90093072e3efb5fc2ec8598b 100644 --- a/README.md +++ b/README.md @@ -386,7 +386,7 @@ sync will create the database indexes necessary for hive server to efficiently p ### Cache layer Synchronizes the latest state of posts and users, allowing us to serve discussions and lists of posts with all expected -information (title, preview, image, payout, votes, etc) without needing `hived`. This layer is first built once the +information (title, image, payout, votes, etc) without needing `hived`. This layer is first built once the initial core indexing is complete. Incoming blocks trigger cache updates (including recalculation of trending score) for any posts referenced in `comment` or `vote` operations. There is a sweep to paid out posts to ensure they are updated in full with their final state. diff --git a/hive/db/schema.py b/hive/db/schema.py index 4f8de590105b11e921810524c782945ded1e1772..31275d7e4a5ae32a02e89271c3be6a0d219dc187 100644 --- a/hive/db/schema.py +++ b/hive/db/schema.py @@ -177,7 +177,6 @@ def build_metadata(): sa.Column('hive_rowid', sa.BigInteger, server_default=hive_rowid_seq.next_value(), nullable=False), sa.Column('id', sa.Integer, primary_key=True, autoincrement=False), sa.Column('title', VARCHAR(512), nullable=False, server_default=''), - sa.Column('preview', VARCHAR(1024), nullable=False, server_default=''), # first 1k of 'body' sa.Column('img_url', VARCHAR(1024), nullable=False, server_default=''), # first 'image' from 'json' sa.Column('body', TEXT, nullable=False, server_default=''), sa.Column('json', TEXT, nullable=False, server_default=''), diff --git a/hive/db/sql_scripts/get_post_view_by_id.sql b/hive/db/sql_scripts/get_post_view_by_id.sql index ed3ae1b38ab044bd37fb17754c091040659d23ab..1d9e5b36258be5cffbfdde931fe296e9d2ecfa1a 100644 --- a/hive/db/sql_scripts/get_post_view_by_id.sql +++ b/hive/db/sql_scripts/get_post_view_by_id.sql @@ -13,7 +13,6 @@ CREATE TYPE hivemind_app.get_post_view_by_id_return_t AS( title character varying(512), body text, img_url character varying(1024), - preview character varying(1024), category character varying(255) COLLATE pg_catalog."C", category_id integer, depth smallint, @@ -84,7 +83,6 @@ BEGIN hpd.title, hpd.body, hpd.img_url, - hpd.preview, hcd.category, hp.category_id, hp.depth, @@ -219,7 +217,6 @@ CREATE TYPE hivemind_app.get_full_post_view_by_id_return_t AS( title character varying(512), body text, img_url character varying(1024), - preview character varying(1024), category character varying(255) COLLATE pg_catalog."C", category_id integer, depth smallint, @@ -291,7 +288,6 @@ BEGIN hpd.title, hpd.body, hpd.img_url, - hpd.preview, hcd.category, hp.category_id, hp.depth, diff --git a/hive/indexer/post_data_cache.py b/hive/indexer/post_data_cache.py index f78b5b4e80d6e7b5b0fd93c15ed7934358bfb4ae..7a0c4b95a7ee4a25c0bad3439fc9811f82e6166b 100644 --- a/hive/indexer/post_data_cache.py +++ b/hive/indexer/post_data_cache.py @@ -51,10 +51,9 @@ class PostDataCache(DbAdapterHolder): for k, data in cls._data.items(): title = 'NULL' if data['title'] is None else f"{escape_characters(data['title'])}" body = 'NULL' if data['body'] is None else f"{escape_characters(data['body'])}" - preview = 'NULL' if data['body'] is None else f"{escape_characters(data['body'][0:1024])}" json = 'NULL' if data['json'] is None else f"{escape_characters(data['json'])}" img_url = 'NULL' if data['img_url'] is None else f"{escape_characters(data['img_url'])}" - value = f"({k},{title},{preview},{img_url},{body},{json})" + value = f"({k},{title},{img_url},{body},{json})" if data['is_new_post']: values_insert.append(value) else: @@ -64,7 +63,7 @@ class PostDataCache(DbAdapterHolder): if len(values_insert) > 0: sql = f""" INSERT INTO - {SCHEMA_NAME}.hive_post_data (id, title, preview, img_url, body, json) + {SCHEMA_NAME}.hive_post_data (id, title, img_url, body, json) VALUES """ sql += ','.join(values_insert) @@ -77,7 +76,6 @@ class PostDataCache(DbAdapterHolder): sql = f""" UPDATE {SCHEMA_NAME}.hive_post_data AS hpd SET title = COALESCE( data_source.title, hpd.title ), - preview = COALESCE( data_source.preview, hpd.preview ), img_url = COALESCE( data_source.img_url, hpd.img_url ), body = COALESCE( data_source.body, hpd.body ), json = COALESCE( data_source.json, hpd.json ) @@ -87,7 +85,7 @@ class PostDataCache(DbAdapterHolder): """ sql += ','.join(values_update) sql += """ - ) AS T(id, title, preview, img_url, body, json) + ) AS T(id, title, img_url, body, json) ) AS data_source WHERE hpd.id = data_source.id """