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
4
Expand
Based on
!819
Edited
1 week ago
by
Krzysztof Leśniak
0
0
Merge request reports
Compare
version 4
version 8
e26892d5
3 days ago
version 7
b6e98c4f
3 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 5
latest version
0623acfc
90 commits,
17 hours ago
version 8
e26892d5
83 commits,
3 days ago
version 7
b6e98c4f
83 commits,
3 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
4 files
+
106
−
54
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
hive/db/sql_scripts/notifications_view.sql
+
20
−
49
Options
@@ -5,10 +5,13 @@ RETURNS INT
LANGUAGE
'sql'
IMMUTABLE
AS
$
BODY
$
SELECT
CASE
SELECT
CASE
_abs_rshares
=
0
WHEN
TRUE
THEN
CAST
(
0
AS
INT
)
ELSE
CASE
WHEN
(((
_payout
)
/
_abs_rshares
)
*
1000
*
_rshares
<
20
)
THEN
-
1
ELSE
LEAST
(
100
,
(
LENGTH
(
CAST
(
CAST
(
(
((
_payout
)
/
_abs_rshares
)
*
1000
*
_rshares
)
as
BIGINT
)
as
text
))
-
1
)
*
25
)
END
;
ELSE
LEAST
(
100
,
(
LENGTH
(
CAST
(
CAST
(
(
((
_payout
)
/
_abs_rshares
)
*
1000
*
_rshares
)
as
BIGINT
)
as
text
))
-
1
)
*
25
)
END
END
;
$
BODY
$
;
DROP
FUNCTION
IF
EXISTS
hivemind_app
.
notification_id
CASCADE
;
@@ -41,56 +44,24 @@ AS $BODY$
END
$
BODY
$
;
DROP
FUNCTION
IF
EXISTS
hivemind_app
.
format_vote_value_payload
CASCADE
;
CREATE
OR
REPLACE
FUNCTION
hivemind_app
.
format_vote_value_payload
(
_vote_value
FLOAT
)
RETURNS
VARCHAR
LANGUAGE
'sql'
IMMUTABLE
AS
$
BODY
$
SELECT
CASE
WHEN
_vote_value
<
0
.
01
THEN
''
::
VARCHAR
ELSE
CAST
(
to_char
(
_vote_value
,
'($FM99990.00)'
)
AS
VARCHAR
)
END
$
BODY
$
;
--vote has own score, new communities score as 35 (magic number), persistent notifications are already scored
DROP
VIEW
IF
EXISTS
hivemind_app
.
hive_raw_notifications_view_no_account_score
cascade
;
CREATE
OR
REPLACE
VIEW
hivemind_app
.
hive_raw_notifications_view_no_account_score
AS
SELECT
-- votes
vn
.
block_num
,
vn
.
post_id
,
vn
.
type_id
,
vn
.
created_at
,
vn
.
src
,
vn
.
dst
,
vn
.
dst_post_id
,
vn
.
community
,
vn
.
community_title
,
CASE
WHEN
vn
.
vote_value
<
0
.
01
THEN
''
::
VARCHAR
ELSE
CAST
(
to_char
(
vn
.
vote_value
,
'($FM99990.00)'
)
AS
VARCHAR
)
END
as
payload
,
vn
.
score
FROM
(
SELECT
hv1
.
block_num
,
hpv
.
id
AS
post_id
,
17
AS
type_id
,
hv1
.
last_update
AS
created_at
,
hv1
.
voter_id
AS
src
,
hpv
.
author_id
AS
dst
,
hpv
.
id
AS
dst_post_id
,
''
::
VARCHAR
(
16
)
AS
community
,
''
::
VARCHAR
AS
community_title
,
hivemind_app
.
calculate_value_of_vote_on_post
(
hpv
.
payout
+
hpv
.
pending_payout
,
hpv
.
rshares
,
hv1
.
rshares
)
AS
vote_value
,
hivemind_app
.
calculate_notify_vote_score
(
hpv
.
payout
+
hpv
.
pending_payout
,
hpv
.
abs_rshares
,
hv1
.
rshares
)
AS
score
FROM
hivemind_app
.
hive_votes
hv1
JOIN
(
SELECT
hpvi
.
id
,
hpvi
.
author_id
,
hpvi
.
payout
,
hpvi
.
pending_payout
,
hpvi
.
abs_rshares
,
hpvi
.
vote_rshares
as
rshares
FROM
hivemind_app
.
hive_posts
hpvi
WHERE
hpvi
.
block_num
>
hivemind_app
.
block_before_head
(
'97 days'
::
interval
)
)
hpv
ON
hv1
.
post_id
=
hpv
.
id
WHERE
hv1
.
rshares
>=
10
e9
)
as
vn
WHERE
vn
.
vote_value
>=
0
.
02
UNION
ALL
SELECT
-- new community
hc
.
block_num
as
block_num
,
0
as
post_id
Loading