Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hivemind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
hivemind
Merge requests
!863
Draft: refactor follows and update_nofications indexing
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Draft: refactor follows and update_nofications indexing
267-update-notification-cache
into
develop
Overview
0
Commits
90
Pipelines
0
Changes
670
Open
Dan Notestein
requested to merge
267-update-notification-cache
into
develop
2 weeks ago
Overview
0
Commits
90
Pipelines
0
Changes
17
Expand
Based on
!819
Edited
1 week ago
by
Krzysztof Leśniak
0
0
Merge request reports
Compare
version 1
version 8
e26892d5
3 days ago
version 7
b6e98c4f
4 days ago
version 6
e23b6b20
5 days ago
version 5
b324dc58
1 week ago
version 4
08bda96a
1 week ago
version 3
06934459
1 week ago
version 2
1e627fa0
2 weeks ago
version 1
79277ddd
2 weeks ago
develop (HEAD)
and
version 6
latest version
0623acfc
90 commits,
1 day ago
version 8
e26892d5
83 commits,
3 days ago
version 7
b6e98c4f
83 commits,
4 days ago
version 6
e23b6b20
81 commits,
5 days ago
version 5
b324dc58
80 commits,
1 week ago
version 4
08bda96a
79 commits,
1 week ago
version 3
06934459
78 commits,
1 week ago
version 2
1e627fa0
76 commits,
2 weeks ago
version 1
79277ddd
74 commits,
2 weeks ago
Show latest version
17 files
+
377
−
206
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
17
Search (e.g. *.vue) (Ctrl+P)
hive/db/sql_scripts/hive_post_operations.sql
+
65
−
0
Options
@@ -351,6 +351,71 @@ END
$
function
$
;
DROP
FUNCTION
IF
EXISTS
hivemind_app
.
process_hive_post_mentions
;
CREATE
OR
REPLACE
FUNCTION
hivemind_app
.
process_hive_post_mentions
(
_post_id
hivemind_app
.
hive_posts
.
id
%
TYPE
)
RETURNS
SETOF
BIGINT
LANGUAGE
plpgsql
AS
$
function
$
BEGIN
-- With clause is inlined, modified call to reptracker_endpoints.get_account_reputation.
-- Reputation is multiplied by 7.5 rather than 9 to bring the max value to 100 rather than 115.
-- In case of reputation being 0, the score is set to 25 rather than 0.
RETURN
query
WITH
log_account_rep
AS
(
SELECT
account_id
,
LOG
(
10
,
ABS
(
nullif
(
reputation
,
0
)))
AS
rep
,
(
CASE
WHEN
reputation
<
0
THEN
-
1
ELSE
1
END
)
AS
is_neg
FROM
reptracker_app
.
account_reputations
),
calculate_rep
AS
(
SELECT
account_id
,
GREATEST
(
lar
.
rep
-
9
,
0
)
*
lar
.
is_neg
AS
rep
FROM
log_account_rep
lar
),
final_rep
AS
(
SELECT
account_id
,
(
cr
.
rep
*
7
.
5
+
25
)::
INT
AS
rep
FROM
calculate_rep
AS
cr
),
mentions
AS
(
SELECT
DISTINCT
_post_id
AS
post_id
,
T
.
author_id
,
ha
.
id
AS
account_id
,
T
.
block_num
FROM
hivemind_app
.
hive_accounts
ha
INNER
JOIN
(
SELECT
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'
)
AS
mention
,
hp
.
author_id
,
hp
.
block_num
FROM
hivemind_app
.
hive_posts
hp
INNER
JOIN
hivemind_app
.
hive_post_data
hpd
ON
hp
.
id
=
hpd
.
id
WHERE
hp
.
id
=
_post_id
)
AS
T
)
AS
T
ON
ha
.
name
=
T
.
mention
WHERE
ha
.
id
!=
T
.
author_id
ORDER
BY
T
.
block_num
,
ha
.
id
)
INSERT
INTO
hivemind_app
.
hive_notification_cache
(
block_num
,
type_id
,
created_at
,
src
,
dst
,
dst_post_id
,
post_id
,
score
,
payload
,
community
,
community_title
)
SELECT
hm
.
block_num
,
16
,
(
SELECT
hb
.
created_at
FROM
hivemind_app
.
blocks_view
hb
WHERE
hb
.
num
=
(
hm
.
block_num
-
1
))
AS
created_at
,
hm
.
author_id
,
hm
.
account_id
,
hm
.
post_id
,
hm
.
post_id
,
COALESCE
(
rep
.
rep
,
25
),
''
,
''
,
''
FROM
mentions
AS
hm
JOIN
hivemind_app
.
hive_accounts
AS
a
ON
hm
.
account_id
=
a
.
id
LEFT
JOIN
final_rep
AS
rep
ON
a
.
haf_id
=
rep
.
account_id
WHERE
hm
.
block_num
>
hivemind_app
.
block_before_irreversible
(
'90 days'
)
AND
COALESCE
(
rep
.
rep
,
25
)
>
0
ORDER
BY
hm
.
block_num
,
created_at
,
hm
.
author_id
,
hm
.
account_id
ON
CONFLICT
(
src
,
dst
,
post_id
)
WHERE
type_id
=
16
DO
UPDATE
SET
block_num
=
EXCLUDED
.
block_num
,
created_at
=
EXCLUDED
.
created_at
RETURNING
id
;
END
;
$
function
$
;
DROP
FUNCTION
IF
EXISTS
hivemind_app
.
delete_hive_post
(
character
varying
,
character
varying
,
character
varying
,
integer
,
timestamp
)
;
CREATE
OR
REPLACE
FUNCTION
hivemind_app
.
delete_hive_post
(
Loading