Skip to content
Snippets Groups Projects
Commit beae8766 authored by Bartek Wrona's avatar Bartek Wrona Committed by Marcin
Browse files

Fixed bug in mentions update ignoring posts having creation time earlier than...

Fixed bug in mentions update ignoring posts having creation time earlier than block they have processed by blockchain
parent 166327bf
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!295Fixed bug in mentions update ignoring posts having creation time earlier than...
...@@ -6,15 +6,11 @@ LANGUAGE 'plpgsql' ...@@ -6,15 +6,11 @@ LANGUAGE 'plpgsql'
AS AS
$function$ $function$
DECLARE DECLARE
FIRST_BLOCK_TIME TIMESTAMP; __block_limit INT := 1200*24*90; --- 1200 blocks is equal to 1hr, so 90 days
LAST_BLOCK_TIME TIMESTAMP;
BEGIN BEGIN
FIRST_BLOCK_TIME = ( SELECT created_at FROM hive_blocks WHERE num = _first_block ); IF (_last_block - __block_limit) > _first_block THEN
LAST_BLOCK_TIME = ( SELECT created_at FROM hive_blocks WHERE num = _last_block ); _first_block = _last_block - __block_limit;
IF (LAST_BLOCK_TIME - '90 days'::interval) > FIRST_BLOCK_TIME THEN
FIRST_BLOCK_TIME = LAST_BLOCK_TIME - '90 days'::interval;
END IF; END IF;
INSERT INTO hive_mentions( post_id, account_id, block_num ) INSERT INTO hive_mentions( post_id, account_id, block_num )
...@@ -23,17 +19,14 @@ BEGIN ...@@ -23,17 +19,14 @@ BEGIN
hive_accounts ha hive_accounts ha
INNER JOIN INNER JOIN
( (
SELECT T.id_post, LOWER( ( SELECT trim( T.mention::text, '{""}') ) ) mention, T.author_id, T.block_num SELECT T.id_post, LOWER( ( SELECT trim( T.mention::text, '{""}') ) ) AS mention, T.author_id, T.block_num
FROM FROM
( (
SELECT SELECT
hp.id, REGEXP_MATCHES( hpd.body, '(?:^|[^a-zA-Z0-9_!#$%&*@\\/])(?:@)([a-zA-Z0-9\\.-]{1,16}[a-zA-Z0-9])(?![a-z])', 'g') mention, hp.author_id, hp.block_num hp.id, REGEXP_MATCHES( hpd.body, '(?:^|[^a-zA-Z0-9_!#$%&*@\\/])(?:@)([a-zA-Z0-9\\.-]{1,16}[a-zA-Z0-9])(?![a-z])', 'g') AS mention, hp.author_id, hp.block_num
FROM hive_posts hp FROM hive_posts hp
INNER JOIN hive_post_data hpd ON hp.id = hpd.id INNER JOIN hive_post_data hpd ON hp.id = hpd.id
WHERE WHERE hp.block_num >= _first_block
(
hp.created_at >= FIRST_BLOCK_TIME
)
)T( id_post, mention, author_id, block_num ) )T( id_post, mention, author_id, block_num )
)T( id_post, mention, author_id, block_num ) ON ha.name = T.mention )T( id_post, mention, author_id, block_num ) ON ha.name = T.mention
WHERE ha.id != T.author_id WHERE ha.id != T.author_id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment