Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
beem
Commits
25ce8373
Commit
25ce8373
authored
6 years ago
by
Holger Nahrstaedt
Browse files
Options
Downloads
Patches
Plain Diff
Comment: get_replies added, get_curation_penalty improved and get_rewards fixed
parent
287ab678
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beem/comment.py
+23
-6
23 additions, 6 deletions
beem/comment.py
with
23 additions
and
6 deletions
beem/comment.py
+
23
−
6
View file @
25ce8373
...
@@ -267,7 +267,7 @@ class Comment(BlockchainObject):
...
@@ -267,7 +267,7 @@ class Comment(BlockchainObject):
self
.
refresh
()
self
.
refresh
()
if
estimated_value_SBD
is
None
:
if
estimated_value_SBD
is
None
:
estimated_value_SBD
=
float
(
self
.
reward
)
estimated_value_SBD
=
float
(
self
.
reward
)
t
=
self
.
get_curation_penalty
()
/
100.
t
=
1.0
-
self
.
get_curation_penalty
()
k
=
vote_value_SBD
/
(
vote_value_SBD
+
float
(
self
.
reward
))
k
=
vote_value_SBD
/
(
vote_value_SBD
+
float
(
self
.
reward
))
K
=
(
1
-
math
.
sqrt
(
1
-
k
))
/
4
/
k
K
=
(
1
-
math
.
sqrt
(
1
-
k
))
/
4
/
k
return
K
*
vote_value_SBD
*
t
*
math
.
sqrt
(
estimated_value_SBD
)
return
K
*
vote_value_SBD
*
t
*
math
.
sqrt
(
estimated_value_SBD
)
...
@@ -279,6 +279,8 @@ class Comment(BlockchainObject):
...
@@ -279,6 +279,8 @@ class Comment(BlockchainObject):
:param datetime vote_time: A vote time can be given and the curation
:param datetime vote_time: A vote time can be given and the curation
penalty is calculated regarding the given time (default is None)
penalty is calculated regarding the given time (default is None)
When set to None, the current date is used.
When set to None, the current date is used.
:returns: Float number between 0 and 1 (0.0 -> no penalty, 1.0 -> 100 % curation penalty)
:rtype: float
"""
"""
if
vote_time
is
None
:
if
vote_time
is
None
:
...
@@ -289,10 +291,10 @@ class Comment(BlockchainObject):
...
@@ -289,10 +291,10 @@ class Comment(BlockchainObject):
elapsed_seconds
=
(
vote_time
-
self
[
"
created
"
]).
total_seconds
()
elapsed_seconds
=
(
vote_time
-
self
[
"
created
"
]).
total_seconds
()
else
:
else
:
raise
ValueError
(
"
vote_time must be a string or a datetime
"
)
raise
ValueError
(
"
vote_time must be a string or a datetime
"
)
reward
=
(
elapsed_seconds
/
1800
)
*
100
reward
=
(
elapsed_seconds
/
1800
)
if
reward
>
1
00
:
if
reward
>
1
:
reward
=
1
0
0
reward
=
1
.
0
return
reward
return
1.0
-
reward
def
get_vote_with_curation
(
self
,
voter
=
None
,
raw_data
=
False
,
pending_payout_value
=
None
):
def
get_vote_with_curation
(
self
,
voter
=
None
,
raw_data
=
False
,
pending_payout_value
=
None
):
"""
Returns vote for voter. Returns None, if the voter cannot be found in `active_votes`.
"""
Returns vote for voter. Returns None, if the voter cannot be found in `active_votes`.
...
@@ -344,7 +346,7 @@ class Comment(BlockchainObject):
...
@@ -344,7 +346,7 @@ class Comment(BlockchainObject):
"""
"""
if
self
.
is_pending
():
if
self
.
is_pending
():
total_payout
=
Amount
(
self
[
"
pending_payout_value
"
],
steem_instance
=
self
.
steem
)
total_payout
=
Amount
(
self
[
"
pending_payout_value
"
],
steem_instance
=
self
.
steem
)
author_payout
=
self
.
get_author_rewards
()[
"
author
_payout
"
]
author_payout
=
self
.
get_author_rewards
()[
"
total
_payout
_SBD
"
]
curator_payout
=
total_payout
-
author_payout
curator_payout
=
total_payout
-
author_payout
else
:
else
:
total_payout
=
Amount
(
self
[
"
total_payout_value
"
],
steem_instance
=
self
.
steem
)
total_payout
=
Amount
(
self
[
"
total_payout_value
"
],
steem_instance
=
self
.
steem
)
...
@@ -467,6 +469,21 @@ class Comment(BlockchainObject):
...
@@ -467,6 +469,21 @@ class Comment(BlockchainObject):
else
:
else
:
return
self
.
steem
.
rpc
.
get_reblogged_by
(
post_author
,
post_permlink
,
api
=
"
follow
"
)
return
self
.
steem
.
rpc
.
get_reblogged_by
(
post_author
,
post_permlink
,
api
=
"
follow
"
)
def
get_replies
(
self
,
raw_data
=
False
,
identifier
=
None
):
"""
Returns all content replies
"""
if
not
identifier
:
post_author
=
self
[
"
author
"
]
post_permlink
=
self
[
"
permlink
"
]
else
:
[
post_author
,
post_permlink
]
=
resolve_authorperm
(
identifier
)
if
self
.
steem
.
rpc
.
get_use_appbase
():
content_replies
=
self
.
steem
.
rpc
.
get_content_replies
({
'
author
'
:
post_author
,
'
permlink
'
:
post_permlink
},
api
=
"
tags
"
)[
'
discussions
'
]
else
:
content_replies
=
self
.
steem
.
rpc
.
get_content_replies
(
post_author
,
post_permlink
,
api
=
"
tags
"
)
if
raw_data
:
return
content_replies
return
[
Comment
(
c
,
steem_instance
=
self
.
steem
)
for
c
in
content_replies
]
def
get_votes
(
self
):
def
get_votes
(
self
):
"""
Returns all votes as ActiveVotes object
"""
"""
Returns all votes as ActiveVotes object
"""
from
.vote
import
ActiveVotes
from
.vote
import
ActiveVotes
...
...
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