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
b3e16eac
Commit
b3e16eac
authored
7 years ago
by
Tim
Browse files
Options
Downloads
Patches
Plain Diff
fix post fetching, payout stats apis
parent
7af00e83
Branches
bw_mi/hivemind_wit_sa_btracker_rebase
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hive/db/methods.py
+11
-3
11 additions, 3 deletions
hive/db/methods.py
with
11 additions
and
3 deletions
hive/db/methods.py
+
11
−
3
View file @
b3e16eac
...
@@ -159,7 +159,7 @@ async def payouts_total():
...
@@ -159,7 +159,7 @@ async def payouts_total():
WHERE is_paidout = 1 AND payout_at >
'
%s
'
WHERE is_paidout = 1 AND payout_at >
'
%s
'
"""
%
(
precalc_date
)
"""
%
(
precalc_date
)
return
precalc_sum
+
query_one
(
sql
)
return
float
(
precalc_sum
+
query_one
(
sql
)
)
#TODO: decimal
# sum of completed payouts last 24 hrs
# sum of completed payouts last 24 hrs
async
def
payouts_last_24h
():
async
def
payouts_last_24h
():
...
@@ -167,7 +167,7 @@ async def payouts_last_24h():
...
@@ -167,7 +167,7 @@ async def payouts_last_24h():
SELECT SUM(payout) FROM hive_posts_cache
SELECT SUM(payout) FROM hive_posts_cache
WHERE is_paidout = 1 AND payout_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)
WHERE is_paidout = 1 AND payout_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)
"""
"""
return
query_one
(
sql
)
return
float
(
query_one
(
sql
)
)
# TODO: decimal
# unused
# unused
def
get_reblogs_since
(
account
:
str
,
since
:
str
):
def
get_reblogs_since
(
account
:
str
,
since
:
str
):
...
@@ -203,6 +203,14 @@ def get_posts(ids, context = None):
...
@@ -203,6 +203,14 @@ def get_posts(ids, context = None):
'
voted
'
:
context
in
voters
'
voted
'
:
context
in
voters
}
}
# TODO: Object of type 'Decimal' is not JSON serializable
obj
[
'
payout
'
]
=
float
(
obj
[
'
payout
'
])
obj
[
'
promoted
'
]
=
float
(
obj
[
'
promoted
'
])
# TODO: Object of type 'datetime' is not JSON serializable
obj
[
'
created_at
'
]
=
str
(
obj
[
'
created_at
'
])
obj
[
'
payout_at
'
]
=
str
(
obj
[
'
payout_at
'
])
obj
.
pop
(
'
votes
'
)
# temp
obj
.
pop
(
'
votes
'
)
# temp
obj
.
pop
(
'
json
'
)
# temp
obj
.
pop
(
'
json
'
)
# temp
posts_by_id
[
row
[
'
post_id
'
]]
=
obj
posts_by_id
[
row
[
'
post_id
'
]]
=
obj
...
@@ -219,7 +227,7 @@ def get_posts(ids, context = None):
...
@@ -219,7 +227,7 @@ def get_posts(ids, context = None):
# builds SQL query to pull a list of posts for any sort order or tag
# builds SQL query to pull a list of posts for any sort order or tag
# sort can be: trending hot new promoted
# sort can be: trending hot new promoted
def
get_discussions_by_sort_and_tag
(
sort
,
tag
,
skip
,
limit
,
context
=
None
):
async
def
get_discussions_by_sort_and_tag
(
sort
,
tag
,
skip
,
limit
,
context
=
None
):
if
skip
>
5000
:
if
skip
>
5000
:
raise
Exception
(
"
cannot skip {} results
"
.
format
(
skip
))
raise
Exception
(
"
cannot skip {} results
"
.
format
(
skip
))
if
limit
>
100
:
if
limit
>
100
:
...
...
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