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
f7d5c927
Commit
f7d5c927
authored
5 years ago
by
roadscape
Browse files
Options
Downloads
Patches
Plain Diff
force child recount when child node is deleted, fix
#208
parent
0b237262
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
hive/indexer/posts.py
+15
-0
15 additions, 0 deletions
hive/indexer/posts.py
with
15 additions
and
0 deletions
hive/indexer/posts.py
+
15
−
0
View file @
f7d5c927
...
@@ -156,6 +156,11 @@ class Posts:
...
@@ -156,6 +156,11 @@ class Posts:
CachedPost
.
delete
(
pid
,
op
[
'
author
'
],
op
[
'
permlink
'
])
CachedPost
.
delete
(
pid
,
op
[
'
author
'
],
op
[
'
permlink
'
])
if
depth
==
0
:
if
depth
==
0
:
FeedCache
.
delete
(
pid
)
FeedCache
.
delete
(
pid
)
else
:
# force parent child recount when child is deleted
prnt
=
cls
.
_get_parent_by_child_id
(
pid
)
CachedPost
.
recount
(
prnt
[
'
author
'
],
prnt
[
'
permlink
'
],
prnt
[
'
id
'
])
@classmethod
@classmethod
def
update
(
cls
,
op
,
date
,
pid
):
def
update
(
cls
,
op
,
date
,
pid
):
...
@@ -168,6 +173,16 @@ class Posts:
...
@@ -168,6 +173,16 @@ class Posts:
if
not
DbState
.
is_initial_sync
():
if
not
DbState
.
is_initial_sync
():
CachedPost
.
update
(
op
[
'
author
'
],
op
[
'
permlink
'
],
pid
)
CachedPost
.
update
(
op
[
'
author
'
],
op
[
'
permlink
'
],
pid
)
@classmethod
def
_get_parent_by_child_id
(
cls
,
child_id
):
"""
Get parent
'
s `id`, `author`, `permlink` by child id.
"""
sql
=
"""
SELECT id, author, permlink FROM hive_posts
WHERE id = (SELECT parent_id FROM hive_posts
WHERE id = :child_id)
"""
result
=
DB
.
query_row
(
sql
,
child_id
=
child_id
)
assert
result
,
"
parent of %d not found
"
%
child_id
return
result
@classmethod
@classmethod
def
_insert_feed_cache
(
cls
,
post
):
def
_insert_feed_cache
(
cls
,
post
):
"""
Insert the new post into feed cache if it
'
s not a comment.
"""
"""
Insert the new post into feed cache if it
'
s not a comment.
"""
...
...
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