Skip to content
Snippets Groups Projects
Commit 917c7f73 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'mentions_collection_fix' into 'develop'

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

See merge request !295
parents 166327bf 1f187a05
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'
AS
$function$
DECLARE
FIRST_BLOCK_TIME TIMESTAMP;
LAST_BLOCK_TIME TIMESTAMP;
__block_limit INT := 1200*24*90; --- 1200 blocks is equal to 1hr, so 90 days
BEGIN
FIRST_BLOCK_TIME = ( SELECT created_at FROM hive_blocks WHERE num = _first_block );
LAST_BLOCK_TIME = ( SELECT created_at FROM hive_blocks WHERE num = _last_block );
IF (LAST_BLOCK_TIME - '90 days'::interval) > FIRST_BLOCK_TIME THEN
FIRST_BLOCK_TIME = LAST_BLOCK_TIME - '90 days'::interval;
IF (_last_block - __block_limit) > _first_block THEN
_first_block = _last_block - __block_limit;
END IF;
INSERT INTO hive_mentions( post_id, account_id, block_num )
......@@ -23,20 +19,18 @@ BEGIN
hive_accounts ha
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
(
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
INNER JOIN hive_post_data hpd ON hp.id = hpd.id
WHERE
(
hp.created_at >= FIRST_BLOCK_TIME
)
INNER JOIN hive_post_data hpd ON hp.id = hpd.id
WHERE hp.block_num >= _first_block
)T( id_post, mention, author_id, block_num )
)T( id_post, mention, author_id, block_num ) ON ha.name = T.mention
WHERE ha.id != T.author_id
ORDER BY T.id_post
ON CONFLICT DO NOTHING;
END
......
Subproject commit e1439046adf7900ba3d6cbaeb5615d4dc6c837b5
Subproject commit ee534480e5739b75968089859ee3663dfdabb126
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