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
Commits
ed5582c0
Commit
ed5582c0
authored
4 years ago
by
Andrzej Lisak
Browse files
Options
Downloads
Patches
Plain Diff
[ABW]: [Fix] votes now properly retain weight/rshares of last effective_comment_vote_operation
parent
03edafa1
No related branches found
No related tags found
4 merge requests
!456
Release candidate v1 24
,
!230
Setup monitoring with pghero
,
!135
Enable postgres monitoring on CI server
,
!69
Votes now properly retain weight/rshares of last effective_comment_vote_operation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hive/indexer/blocks.py
+1
-1
1 addition, 1 deletion
hive/indexer/blocks.py
hive/indexer/votes.py
+41
-19
41 additions, 19 deletions
hive/indexer/votes.py
tests/tests_api
+1
-1
1 addition, 1 deletion
tests/tests_api
with
43 additions
and
21 deletions
hive/indexer/blocks.py
+
1
−
1
View file @
ed5582c0
...
...
@@ -238,7 +238,7 @@ class Blocks:
if
vote_ops
is
not
None
:
for
k
,
v
in
vote_ops
.
items
():
Votes
.
effective_comment_vote_op
(
k
,
v
,
cls
.
_head_block_date
)
Votes
.
effective_comment_vote_op
(
k
,
v
)
if
Posts
.
comment_payout_ops
:
cls
.
ops_stats
=
Blocks
.
merge_ops_stats
(
cls
.
ops_stats
,
comment_payout_stats
)
...
...
This diff is collapsed.
Click to expand it.
hive/indexer/votes.py
+
41
−
19
View file @
ed5582c0
...
...
@@ -62,16 +62,21 @@ class Votes:
key
=
voter
+
"
/
"
+
author
+
"
/
"
+
permlink
cls
.
_votes_data
[
key
]
=
dict
(
voter
=
voter
,
author
=
author
,
permlink
=
permlink
,
vote_percent
=
weight
,
weight
=
0
,
rshares
=
0
,
last_update
=
date
)
if
key
in
cls
.
_votes_data
:
cls
.
_votes_data
[
key
][
"
vote_percent
"
]
=
weight
cls
.
_votes_data
[
key
][
"
last_update
"
]
=
date
else
:
cls
.
_votes_data
[
key
]
=
dict
(
voter
=
voter
,
author
=
author
,
permlink
=
permlink
,
vote_percent
=
weight
,
weight
=
0
,
rshares
=
0
,
last_update
=
date
,
is_effective
=
False
)
@classmethod
def
effective_comment_vote_op
(
cls
,
key
,
vop
,
date
):
def
effective_comment_vote_op
(
cls
,
key
,
vop
):
"""
Process effective_comment_vote_operation
"""
if
(
cls
.
inside_flush
):
...
...
@@ -80,9 +85,9 @@ class Votes:
assert
key
in
cls
.
_votes_data
cls
.
_votes_data
[
key
][
"
weight
"
]
=
vop
[
"
weight
"
]
cls
.
_votes_data
[
key
][
"
rshares
"
]
=
vop
[
"
rshares
"
]
cls
.
_votes_data
[
key
][
"
last_update
"
]
=
dat
e
cls
.
_votes_data
[
key
][
"
weight
"
]
=
vop
[
"
weight
"
]
cls
.
_votes_data
[
key
][
"
rshares
"
]
=
vop
[
"
rshares
"
]
cls
.
_votes_data
[
key
][
"
is_effective
"
]
=
Tru
e
@classmethod
def
flush
(
cls
):
...
...
@@ -106,32 +111,49 @@ class Votes:
ON CONFLICT ON CONSTRAINT hive_votes_ux1 DO
UPDATE
SET
weight =
(CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.post_id) WHEN true THEN hive_votes.weight ELSE EXCLUDED.weight END)
,
rshares =
(CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.post_id) WHEN true THEN hive_votes.rshares ELSE EXCLUDED.rshares END)
,
weight =
{}.weight
,
rshares =
{}.rshares
,
vote_percent = EXCLUDED.vote_percent,
last_update = EXCLUDED.last_update,
num_changes = hive_votes.num_changes + 1
WHERE hive_votes.voter_id = EXCLUDED.voter_id and hive_votes.author_id = EXCLUDED.author_id and hive_votes.permlink_id = EXCLUDED.permlink_id;
"""
# WHERE clause above seems superfluous (and works all the same without it, at least up to 5mln)
values
=
[]
values_skip
=
[]
values_override
=
[]
values_limit
=
1000
for
_
,
vd
in
cls
.
_votes_data
.
items
():
values
=
None
on_conflict_data_source
=
None
if
vd
[
'
is_effective
'
]:
values
=
values_override
on_conflict_data_source
=
'
EXCLUDED
'
else
:
values
=
values_skip
on_conflict_data_source
=
'
hive_votes
'
values
.
append
(
"
(
'
{}
'
,
'
{}
'
,
'
{}
'
, {}, {}, {},
'
{}
'
::timestamp)
"
.
format
(
vd
[
'
voter
'
],
vd
[
'
author
'
],
vd
[
'
permlink
'
],
vd
[
'
weight
'
],
vd
[
'
rshares
'
],
vd
[
'
vote_percent
'
],
vd
[
'
last_update
'
]))
if
len
(
values
)
>=
values_limit
:
values_str
=
'
,
'
.
join
(
values
)
actual_query
=
sql
.
format
(
values_str
)
actual_query
=
sql
.
format
(
values_str
,
on_conflict_data_source
,
on_conflict_data_source
)
DB
.
query
(
actual_query
)
values
.
clear
()
if
len
(
values
)
>
0
:
values_str
=
'
,
'
.
join
(
values
)
actual_query
=
sql
.
format
(
values_str
)
if
len
(
values_skip
)
>
0
:
values_str
=
'
,
'
.
join
(
values_skip
)
actual_query
=
sql
.
format
(
values_str
,
'
hive_votes
'
,
'
hive_votes
'
)
DB
.
query
(
actual_query
)
values_skip
.
clear
()
if
len
(
values_override
)
>
0
:
values_str
=
'
,
'
.
join
(
values_override
)
actual_query
=
sql
.
format
(
values_str
,
'
EXCLUDED
'
,
'
EXCLUDED
'
)
DB
.
query
(
actual_query
)
values
.
clear
()
values
_override
.
clear
()
cls
.
_votes_data
.
clear
()
cls
.
inside_flush
=
False
This diff is collapsed.
Click to expand it.
tests_api
@
dfd35323
Compare
619f51ed
...
dfd35323
Subproject commit
619f51ed6c85a016621b12fa1264c12c7d3d3156
Subproject commit
dfd353231403e3613f0a5e1bdcbdca7a8d4f42fa
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment