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
ad40e845
Commit
ad40e845
authored
4 years ago
by
Mariusz Trela
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#47
- `is_paidout` is calculated correctly
parent
025dae30
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
,
!61
Issue #47 - test database_api get_payout_stats fail
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hive/indexer/blocks.py
+1
-3
1 addition, 3 deletions
hive/indexer/blocks.py
hive/indexer/posts.py
+54
-31
54 additions, 31 deletions
hive/indexer/posts.py
with
55 additions
and
34 deletions
hive/indexer/blocks.py
+
1
−
3
View file @
ad40e845
...
@@ -123,9 +123,7 @@ class Blocks:
...
@@ -123,9 +123,7 @@ class Blocks:
vote_ops
.
append
(
vop
)
vote_ops
.
append
(
vop
)
elif
op_type
==
'
comment_payout_update_operation
'
:
elif
op_type
==
'
comment_payout_update_operation
'
:
key
=
"
{}/{}
"
.
format
(
op_value
[
'
author
'
],
op_value
[
'
permlink
'
])
key
=
"
{}/{}
"
.
format
(
op_value
[
'
author
'
],
op_value
[
'
permlink
'
])
#Later these values are not used
val
=
{
'
is_paidout
'
:
op_value
[
'
is_paidout
'
]}
val
=
{
'
val
'
:
'
key
'
}
vote_ops
.
append
(
vop
)
if
key
is
not
None
and
val
is
not
None
:
if
key
is
not
None
and
val
is
not
None
:
if
key
in
comment_payout_ops
:
if
key
in
comment_payout_ops
:
...
...
This diff is collapsed.
Click to expand it.
hive/indexer/posts.py
+
54
−
31
View file @
ad40e845
...
@@ -16,7 +16,7 @@ from hive.indexer.community import Community, START_DATE
...
@@ -16,7 +16,7 @@ from hive.indexer.community import Community, START_DATE
from
hive.indexer.notify
import
Notify
from
hive.indexer.notify
import
Notify
from
hive.indexer.post_data_cache
import
PostDataCache
from
hive.indexer.post_data_cache
import
PostDataCache
from
hive.indexer.tags
import
Tags
from
hive.indexer.tags
import
Tags
from
hive.utils.normalize
import
legacy_amount
,
asset_to_hbd_hive
from
hive.utils.normalize
import
sbd_amount
,
legacy_amount
,
asset_to_hbd_hive
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
DB
=
Db
.
instance
()
DB
=
Db
.
instance
()
...
@@ -150,18 +150,20 @@ class Posts:
...
@@ -150,18 +150,20 @@ class Posts:
ops_stats
=
{}
ops_stats
=
{}
sql
=
"""
sql
=
"""
UPDATE hive_posts AS ihp SET
UPDATE hive_posts AS ihp SET
total_payout_value = COALESCE( data_source.total_payout_value, ihp.total_payout_value ),
total_payout_value = COALESCE( data_source.total_payout_value, ihp.total_payout_value ),
curator_payout_value = COALESCE( data_source.curator_payout_value, ihp.curator_payout_value ),
curator_payout_value = COALESCE( data_source.curator_payout_value, ihp.curator_payout_value ),
author_rewards = COALESCE( CAST( data_source.author_rewards as INT8 ), ihp.author_rewards ),
author_rewards = COALESCE( CAST( data_source.author_rewards as INT8 ), ihp.author_rewards ),
author_rewards_hive = COALESCE( CAST( data_source.author_rewards_hive as INT8 ), ihp.author_rewards_hive ),
author_rewards_hive = COALESCE( CAST( data_source.author_rewards_hive as INT8 ), ihp.author_rewards_hive ),
author_rewards_hbd = COALESCE( CAST( data_source.author_rewards_hbd as INT8 ), ihp.author_rewards_hbd ),
author_rewards_hbd = COALESCE( CAST( data_source.author_rewards_hbd as INT8 ), ihp.author_rewards_hbd ),
author_rewards_vests = COALESCE( CAST( data_source.author_rewards_vests as INT8 ), ihp.author_rewards_vests ),
author_rewards_vests = COALESCE( CAST( data_source.author_rewards_vests as INT8 ), ihp.author_rewards_vests ),
payout = COALESCE( CAST( data_source.payout as DECIMAL ), ihp.payout ),
payout = COALESCE( CAST( data_source.payout as DECIMAL ), ihp.payout ),
pending_payout = COALESCE( CAST( data_source.pending_payout as DECIMAL ), ihp.pending_payout ),
pending_payout = COALESCE( CAST( data_source.pending_payout as DECIMAL ), ihp.pending_payout ),
last_payout = data_source.last_payout,
payout_at = COALESCE( CAST( data_source.payout_at as TIMESTAMP ), ihp.payout_at ),
cashout_time = data_source.cashout_time,
updated_at = data_source.updated_at,
is_paidout = data_source.is_paidout
last_payout = COALESCE( CAST( data_source.last_payout as TIMESTAMP ), ihp.last_payout ),
FROM
cashout_time = COALESCE( CAST( data_source.cashout_time as TIMESTAMP ), ihp.cashout_time ),
is_paidout = COALESCE( CAST( data_source.is_paidout as BOOLEAN ), ihp.is_paidout )
FROM
(
(
SELECT ha_a.id as author_id, hpd_p.id as permlink_id,
SELECT ha_a.id as author_id, hpd_p.id as permlink_id,
t.total_payout_value,
t.total_payout_value,
...
@@ -172,6 +174,8 @@ class Posts:
...
@@ -172,6 +174,8 @@ class Posts:
t.author_rewards_vests,
t.author_rewards_vests,
t.payout,
t.payout,
t.pending_payout,
t.pending_payout,
t.payout_at,
t.updated_at,
t.last_payout,
t.last_payout,
t.cashout_time,
t.cashout_time,
t.is_paidout
t.is_paidout
...
@@ -189,6 +193,8 @@ class Posts:
...
@@ -189,6 +193,8 @@ class Posts:
author_rewards_vests,
author_rewards_vests,
payout,
payout,
pending_payout,
pending_payout,
payout_at,
updated_at,
last_payout,
last_payout,
cashout_time,
cashout_time,
is_paidout)
is_paidout)
...
@@ -205,25 +211,29 @@ class Posts:
...
@@ -205,25 +211,29 @@ class Posts:
for
k
,
v
in
ops
.
items
():
for
k
,
v
in
ops
.
items
():
author
,
permlink
=
k
.
split
(
"
/
"
)
author
,
permlink
=
k
.
split
(
"
/
"
)
# total payout to curators
# total payout to curators
curator_rewards_sum
=
None
curator_rewards_sum
=
None
# author payouts
# author payouts
author_rewards
=
None
author_rewards
=
None
author_rewards_hive
=
None
author_rewards_hive
=
None
author_rewards_hbd
=
None
author_rewards_hbd
=
None
author_rewards_vests
=
None
author_rewards_vests
=
None
# total payout for comment
# total payout for comment
comment_author_reward
=
None
comment_author_reward
=
None
curator_rewards
=
None
curator_rewards
=
None
total_payout_value
=
None
;
total_payout_value
=
None
;
curator_payout_value
=
None
;
curator_payout_value
=
None
;
beneficiary_payout_value
=
None
;
beneficiary_payout_value
=
None
;
payout
=
None
payout
=
None
pending_payout
=
None
pending_payout
=
None
is_paidout
=
(
date
[
0
:
4
]
==
'
1969
'
)
payout_at
=
None
last_payout
=
None
cashout_time
=
None
is_paidout
=
None
for
operation
in
v
:
for
operation
in
v
:
for
op
,
value
in
operation
.
items
():
for
op
,
value
in
operation
.
items
():
...
@@ -245,9 +255,10 @@ class Posts:
...
@@ -245,9 +255,10 @@ class Posts:
total_payout_value
=
value
[
'
total_payout_value
'
]
total_payout_value
=
value
[
'
total_payout_value
'
]
curator_payout_value
=
value
[
'
curator_payout_value
'
]
curator_payout_value
=
value
[
'
curator_payout_value
'
]
beneficiary_payout_value
=
value
[
'
beneficiary_payout_value
'
]
beneficiary_payout_value
=
value
[
'
beneficiary_payout_value
'
]
elif
op
==
'
effective_comment_vote_operation
'
:
elif
op
==
'
effective_comment_vote_operation
'
:
pending_payout
=
sbd_amount
(
value
[
'
pending_payout
'
]
)
pending_payout
=
sbd_amount
(
value
[
'
pending_payout
'
]
)
elif
op
==
'
comment_payout_update_operation
'
:
is_paidout
=
bool
(
value
[
'
is_paidout
'
]
)
if
curator_rewards_sum
is
not
None
:
if
curator_rewards_sum
is
not
None
:
curator_rewards
=
{
'
amount
'
:
str
(
curator_rewards_sum
),
'
precision
'
:
6
,
'
nai
'
:
'
@@000000037
'
}
curator_rewards
=
{
'
amount
'
:
str
(
curator_rewards_sum
),
'
precision
'
:
6
,
'
nai
'
:
'
@@000000037
'
}
...
@@ -256,7 +267,15 @@ class Posts:
...
@@ -256,7 +267,15 @@ class Posts:
payout
=
sum
([
sbd_amount
(
total_payout_value
),
sbd_amount
(
curator_payout_value
)
])
payout
=
sum
([
sbd_amount
(
total_payout_value
),
sbd_amount
(
curator_payout_value
)
])
pending_payout
=
0
pending_payout
=
0
values
.
append
(
"
(
'
{}
'
,
'
{}
'
, {}, {}, {}, {}, {}, {}, {}, {},
'
{}
'
::timestamp,
'
{}
'
::timestamp, {})
"
.
format
(
#Calculations of all dates
if
(
total_payout_value
is
not
None
):
payout_at
=
date
last_payout
=
date
if
(
is_paidout
is
not
None
):
cashout_time
=
date
values
.
append
(
"
(
'
{}
'
,
'
{}
'
, {}, {}, {}, {}, {}, {}, {}, {}, {},
'
{}
'
::timestamp, {}, {}, {})
"
.
format
(
author
,
author
,
permlink
,
permlink
,
"
NULL
"
if
(
total_payout_value
is
None
)
else
(
"'
{}
'"
.
format
(
legacy_amount
(
total_payout_value
)
)
),
"
NULL
"
if
(
total_payout_value
is
None
)
else
(
"'
{}
'"
.
format
(
legacy_amount
(
total_payout_value
)
)
),
...
@@ -267,9 +286,13 @@ class Posts:
...
@@ -267,9 +286,13 @@ class Posts:
"
NULL
"
if
(
author_rewards_vests
is
None
)
else
author_rewards_vests
,
"
NULL
"
if
(
author_rewards_vests
is
None
)
else
author_rewards_vests
,
"
NULL
"
if
(
payout
is
None
)
else
payout
,
"
NULL
"
if
(
payout
is
None
)
else
payout
,
"
NULL
"
if
(
pending_payout
is
None
)
else
pending_payout
,
"
NULL
"
if
(
pending_payout
is
None
)
else
pending_payout
,
date
,
#last_payout
date
,
#cashout_time
"
NULL
"
if
(
payout_at
is
None
)
else
(
"'
{}
'
::timestamp
"
.
format
(
payout_at
)
),
is_paidout
))
date
,
#updated_at
"
NULL
"
if
(
last_payout
is
None
)
else
(
"'
{}
'
::timestamp
"
.
format
(
last_payout
)
),
"
NULL
"
if
(
cashout_time
is
None
)
else
(
"'
{}
'
::timestamp
"
.
format
(
cashout_time
)
),
"
NULL
"
if
(
is_paidout
is
None
)
else
is_paidout
))
if
len
(
values
)
>=
values_limit
:
if
len
(
values
)
>=
values_limit
:
values_str
=
'
,
'
.
join
(
values
)
values_str
=
'
,
'
.
join
(
values
)
...
...
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