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
aa15d55b
Unverified
Commit
aa15d55b
authored
6 years ago
by
roadscape
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request
#145
from steemit/115-comment-counts
fix child counts
parents
55bcbd75
f288d1cb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hive/indexer/cached_post.py
+10
-1
10 additions, 1 deletion
hive/indexer/cached_post.py
hive/indexer/posts.py
+3
-0
3 additions, 0 deletions
hive/indexer/posts.py
hive/indexer/sync.py
+8
-10
8 additions, 10 deletions
hive/indexer/sync.py
with
21 additions
and
11 deletions
hive/indexer/cached_post.py
+
10
−
1
View file @
aa15d55b
...
@@ -17,7 +17,7 @@ log = logging.getLogger(__name__)
...
@@ -17,7 +17,7 @@ log = logging.getLogger(__name__)
DB
=
Db
.
instance
()
DB
=
Db
.
instance
()
# levels of post dirtiness, in order of decreasing priority
# levels of post dirtiness, in order of decreasing priority
LEVELS
=
[
'
insert
'
,
'
payout
'
,
'
update
'
,
'
upvote
'
]
LEVELS
=
[
'
insert
'
,
'
payout
'
,
'
update
'
,
'
upvote
'
,
'
recount
'
]
def
_keyify
(
items
):
def
_keyify
(
items
):
return
dict
(
map
(
lambda
x
:
(
"
val_%d
"
%
x
[
0
],
x
[
1
]),
enumerate
(
items
)))
return
dict
(
map
(
lambda
x
:
(
"
val_%d
"
%
x
[
0
],
x
[
1
]),
enumerate
(
items
)))
...
@@ -74,6 +74,11 @@ class CachedPost:
...
@@ -74,6 +74,11 @@ class CachedPost:
return
cls
.
_ids
[
url
]
return
cls
.
_ids
[
url
]
raise
Exception
(
"
requested id for %s not in map
"
%
url
)
raise
Exception
(
"
requested id for %s not in map
"
%
url
)
@classmethod
def
recount
(
cls
,
author
,
permlink
,
pid
=
None
):
"""
Force a child re-count.
"""
cls
.
_dirty
(
'
recount
'
,
author
,
permlink
,
pid
)
@classmethod
@classmethod
def
vote
(
cls
,
author
,
permlink
,
pid
=
None
):
def
vote
(
cls
,
author
,
permlink
,
pid
=
None
):
"""
Handle a post dirtied by a `vote` op.
"""
"""
Handle a post dirtied by a `vote` op.
"""
...
@@ -452,6 +457,10 @@ class CachedPost:
...
@@ -452,6 +457,10 @@ class CachedPost:
(
'
children
'
,
"
%d
"
%
min
(
post
[
'
children
'
],
32767
)),
# TODO: #115
(
'
children
'
,
"
%d
"
%
min
(
post
[
'
children
'
],
32767
)),
# TODO: #115
])
])
# if recounting, update the parent next pass.
if
level
==
'
recount
'
and
post
[
'
depth
'
]:
cls
.
recount
(
post
[
'
parent_author
'
],
post
[
'
parent_permlink
'
])
# build the post insert/update SQL, add tag SQLs
# build the post insert/update SQL, add tag SQLs
if
level
==
'
insert
'
:
if
level
==
'
insert
'
:
sql
=
cls
.
_insert
(
values
)
sql
=
cls
.
_insert
(
values
)
...
...
This diff is collapsed.
Click to expand it.
hive/indexer/posts.py
+
3
−
0
View file @
aa15d55b
...
@@ -127,6 +127,9 @@ class Posts:
...
@@ -127,6 +127,9 @@ class Posts:
if
not
DbState
.
is_initial_sync
():
if
not
DbState
.
is_initial_sync
():
CachedPost
.
insert
(
op
[
'
author
'
],
op
[
'
permlink
'
],
post
[
'
id
'
])
CachedPost
.
insert
(
op
[
'
author
'
],
op
[
'
permlink
'
],
post
[
'
id
'
])
if
op
[
'
parent_author
'
]:
# update parent's child count
CachedPost
.
recount
(
op
[
'
parent_author
'
],
op
[
'
parent_permlink
'
],
post
[
'
parent_id
'
])
cls
.
_insert_feed_cache
(
post
)
cls
.
_insert_feed_cache
(
post
)
@classmethod
@classmethod
...
...
This diff is collapsed.
Click to expand it.
hive/indexer/sync.py
+
8
−
10
View file @
aa15d55b
...
@@ -185,19 +185,17 @@ class Sync:
...
@@ -185,19 +185,17 @@ class Sync:
ms
=
(
perf
()
-
start_time
)
*
1000
ms
=
(
perf
()
-
start_time
)
*
1000
log
.
info
(
"
[LIVE] Got block %d at %s --% 4d txs,% 3d posts,% 3d edits,
"
log
.
info
(
"
[LIVE] Got block %d at %s --% 4d txs,% 3d posts,% 3d edits,
"
"
% 3d payouts,% 3d votes,% 3d accts,% 3d follows
--% 5dms%s
"
,
"
% 3d payouts,% 3d votes,% 3d
counts,% 3d
accts,% 3d follows
"
num
,
block
[
'
timestamp
'
],
len
(
block
[
'
transactions
'
]),
"
--% 5dms%s
"
,
num
,
block
[
'
timestamp
'
],
len
(
block
[
'
transactions
'
]),
cnt
[
'
insert
'
],
cnt
[
'
update
'
],
cnt
[
'
payout
'
],
cnt
[
'
upvote
'
],
cnt
[
'
insert
'
],
cnt
[
'
update
'
],
cnt
[
'
payout
'
],
cnt
[
'
upvote
'
],
accts
,
follows
,
int
(
ms
)
,
'
SLOW
'
if
ms
>
1000
else
''
)
cnt
[
'
recount
'
],
accts
,
follows
,
ms
,
'
SLOW
'
if
ms
>
1000
else
''
)
# once per hour, update accounts
#if num % 1200 == 0: #1hr
if
num
%
120
==
0
:
# Accounts.update_ranks() #144
Accounts
.
dirty_oldest
(
10000
)
if
num
%
100
==
0
:
#5min
Accounts
.
dirty_oldest
(
500
)
Accounts
.
flush
(
steemd
,
trx
=
True
)
Accounts
.
flush
(
steemd
,
trx
=
True
)
#Accounts.update_ranks()
if
num
%
20
==
0
:
#1min
# once a minute, update chain props
if
num
%
20
==
0
:
self
.
_update_chain_state
()
self
.
_update_chain_state
()
# refetch dynamic_global_properties, feed price, etc
# refetch dynamic_global_properties, feed price, etc
...
...
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