Skip to content
GitLab
Explore
Sign in
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
3b8dd49d
Commit
3b8dd49d
authored
4 years ago
by
Dariusz Kędzierski
Browse files
Options
Downloads
Patches
Plain Diff
Fix in find root
parent
c98d5dca
No related branches found
No related tags found
5 merge requests
!456
Release candidate v1 24
,
!230
Setup monitoring with pghero
,
!135
Enable postgres monitoring on CI server
,
!16
Dk issue 3 concurrent block query rebase
,
!15
Dk issue 3 concurrent block query
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hive/indexer/posts.py
+12
-5
12 additions, 5 deletions
hive/indexer/posts.py
with
12 additions
and
5 deletions
hive/indexer/posts.py
+
12
−
5
View file @
3b8dd49d
...
@@ -35,18 +35,20 @@ class Posts:
...
@@ -35,18 +35,20 @@ class Posts:
@classmethod
@classmethod
def
find_root
(
cls
,
author
,
permlink
):
def
find_root
(
cls
,
author
,
permlink
):
"""
Find root for post
"""
"""
Find root for post
"""
sql
=
"""
WITH parent AS
print
(
"
A:
"
,
author
,
"
P:
"
,
permlink
)
sql
=
"""
WITH RECURSIVE parent AS
(
(
SELECT id, parent_id, 1 AS
[
level
]
from hive_posts WHERE id = (SELECT hp.id
SELECT id, parent_id, 1 AS level from hive_posts WHERE id = (SELECT hp.id
FROM hive_posts hp
FROM hive_posts hp
LEFT JOIN hive_accounts ha_a ON ha_a.id = hp.author_id
LEFT JOIN hive_accounts ha_a ON ha_a.id = hp.author_id
LEFT JOIN hive_permlink_data hpd_p ON hpd_p.id = hp.permlink_id
LEFT JOIN hive_permlink_data hpd_p ON hpd_p.id = hp.permlink_id
WHERE ha_a.name = :a AND hpd_p.permlink = :p)
WHERE ha_a.name = :a AND hpd_p.permlink = :p)
UNION ALL
UNION ALL
SELECT t.id, t.parent_id,
[
level
]
+ 1 FROM parent
SELECT t.id, t.parent_id, level + 1 FROM parent
INNER JOIN hive_posts t ON t.id = parent.parent_id
INNER JOIN hive_posts t ON t.id = parent.parent_id
)
)
SELECT
TOP 1
id FROM parent ORDER BY
[
level
]
DESC
"""
SELECT id FROM parent ORDER BY level DESC
LIMIT 1
"""
_id
=
DB
.
query_one
(
sql
,
a
=
author
,
p
=
permlink
)
_id
=
DB
.
query_one
(
sql
,
a
=
author
,
p
=
permlink
)
return
_id
return
_id
...
@@ -187,6 +189,7 @@ class Posts:
...
@@ -187,6 +189,7 @@ class Posts:
@classmethod
@classmethod
def
insert
(
cls
,
hived
,
op
,
date
):
def
insert
(
cls
,
hived
,
op
,
date
):
"""
Inserts new post records.
"""
"""
Inserts new post records.
"""
print
(
"
New Post
"
)
# inserting new post
# inserting new post
# * Check for permlink, parent_permlink, root_permlink
# * Check for permlink, parent_permlink, root_permlink
...
@@ -316,6 +319,7 @@ class Posts:
...
@@ -316,6 +319,7 @@ class Posts:
@classmethod
@classmethod
def
undelete
(
cls
,
op
,
date
,
pid
):
def
undelete
(
cls
,
op
,
date
,
pid
):
"""
Re-allocates an existing record flagged as deleted.
"""
"""
Re-allocates an existing record flagged as deleted.
"""
print
(
"
Undelete
"
)
# add category to category table
# add category to category table
if
'
category
'
in
op
:
if
'
category
'
in
op
:
sql
=
"""
sql
=
"""
...
@@ -342,6 +346,8 @@ class Posts:
...
@@ -342,6 +346,8 @@ class Posts:
@classmethod
@classmethod
def
delete
(
cls
,
op
):
def
delete
(
cls
,
op
):
"""
Marks a post record as being deleted.
"""
"""
Marks a post record as being deleted.
"""
print
(
"
Delete post
"
)
pid
,
depth
=
cls
.
get_id_and_depth
(
op
[
'
author
'
],
op
[
'
permlink
'
])
pid
,
depth
=
cls
.
get_id_and_depth
(
op
[
'
author
'
],
op
[
'
permlink
'
])
DB
.
query
(
"
UPDATE hive_posts SET is_deleted =
'
1
'
WHERE id = :id
"
,
id
=
pid
)
DB
.
query
(
"
UPDATE hive_posts SET is_deleted =
'
1
'
WHERE id = :id
"
,
id
=
pid
)
...
@@ -362,6 +368,7 @@ class Posts:
...
@@ -362,6 +368,7 @@ class Posts:
Here we could also build content diffs, but for now just used
Here we could also build content diffs, but for now just used
a signal to update cache record.
a signal to update cache record.
"""
"""
print
(
"
Update post
"
)
# pylint: disable=unused-argument
# pylint: disable=unused-argument
# add category to category table
# add category to category table
...
@@ -518,7 +525,7 @@ class Posts:
...
@@ -518,7 +525,7 @@ class Posts:
if
not
is_valid
:
error
=
'
replying to invalid post
'
if
not
is_valid
:
error
=
'
replying to invalid post
'
elif
is_muted
:
error
=
'
replying to muted post
'
elif
is_muted
:
error
=
'
replying to muted post
'
#find root comment
#find root comment
root_id
=
cls
.
find_root
(
op
[
'
author
'
],
op
[
'
permlink
'
])
root_id
=
cls
.
find_root
(
op
[
'
parent_
author
'
],
op
[
'
parent_
permlink
'
])
sql
=
"""
sql
=
"""
SELECT
SELECT
ha_a.name as author, hpd_p.permlink as permlink
ha_a.name as author, hpd_p.permlink as permlink
...
...
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