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
62ad7900
Commit
62ad7900
authored
4 years ago
by
Dariusz Kędzierski
Committed by
Jason Salyers
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Mimic old hivemind behaviour for follower, following check. Use get_follow_count for testing
parent
2343c3b4
No related branches found
No related tags found
2 merge requests
!456
Release candidate v1 24
,
!370
Jsalyers muting at sql level
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hive/indexer/follow.py
+13
-22
13 additions, 22 deletions
hive/indexer/follow.py
mock_data/block_data/follow_op/mock_block_data_follow.json
+8
-8
8 additions, 8 deletions
mock_data/block_data/follow_op/mock_block_data_follow.json
with
21 additions
and
30 deletions
hive/indexer/follow.py
+
13
−
22
View file @
62ad7900
...
...
@@ -101,21 +101,22 @@ class Follow(DbAdapterHolder):
or
not
'
following
'
in
op
):
return
None
# follower/following is empty
if
not
op
[
'
follower
'
]
or
not
op
[
'
following
'
]:
return
None
op
[
'
following
'
]
=
op
[
'
following
'
]
if
isinstance
(
op
[
'
following
'
],
list
)
else
[
op
[
'
following
'
]]
# additional layer of protection against putting complex data types as user names
# we expecting follower and following entries to be strings
# in older hivemind this check was done in Accounts.exists
# now following can be list of names so we need to check if all entries are strings
for
following
in
op
[
'
following
'
]:
if
not
isinstance
(
following
,
str
):
return
None
if
not
isinstance
(
op
[
'
follower
'
],
str
):
# mimic original behaviour
# if following name does not exist do not process it: basically equal to drop op for single following entry
op
[
'
following
'
]
=
[
op
for
op
in
op
[
'
following
'
]
if
Accounts
.
exists
(
op
)]
# if follower name does not exist drop op
if
not
Accounts
.
exists
(
op
[
'
follower
'
]):
return
None
# follower/following is empty
if
not
op
[
'
follower
'
]
or
not
op
[
'
following
'
]:
if
op
[
'
follower
'
]
in
op
[
'
following
'
]
or
op
[
'
follower
'
]
!=
account
:
return
None
what
=
first
(
op
[
'
what
'
])
or
''
...
...
@@ -127,16 +128,6 @@ class Follow(DbAdapterHolder):
if
what
not
in
defs
:
return
None
all_accounts
=
list
(
op
[
'
following
'
])
all_accounts
.
append
(
op
[
'
follower
'
])
if
(
op
[
'
follower
'
]
in
op
[
'
following
'
]
or
op
[
'
follower
'
]
!=
account
):
return
None
non_existent_names
=
Accounts
.
check_names
(
all_accounts
)
if
non_existent_names
:
log
.
warning
(
"
Follow op validation, following names does not exists in database: {}
"
.
format
(
non_existent_names
))
return
dict
(
flr
=
escape_characters
(
op
[
'
follower
'
]),
flg
=
[
escape_characters
(
following
)
for
following
in
op
[
'
following
'
]],
state
=
defs
[
what
],
...
...
This diff is collapsed.
Click to expand it.
mock_data/block_data/follow_op/mock_block_data_follow.json
+
8
−
8
View file @
62ad7900
...
...
@@ -352,7 +352,7 @@
"tester1"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:[
\"
tester3
\"
,
\"
tester4
\"
],
\"
what
\"
:[
\"
blogo-doggo
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:[
\"
tester3
\"
,
\"
gtg
\"
],
\"
what
\"
:[
\"
blogo-doggo
\"
]}]"
}
},
{
...
...
@@ -363,7 +363,7 @@
"te'%@ter1"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
te'%@ter1
\"
,
\"
following
\"
:[
\"
tester3
\"
,
\"
tester4
\"
],
\"
what
\"
:[
\"
blog
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
te'%@ter1
\"
,
\"
following
\"
:[
\"
gtg
\"
,
\"
tester4
\"
],
\"
what
\"
:[
\"
blog
\"
]}]"
}
},
{
...
...
@@ -374,7 +374,7 @@
"{
\"
tester1
\"
:
\"
tester1
\"
}"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:{
\"
tester1
\"
:
\"
tester1
\"
},
\"
following
\"
:{
\"
tester3
\"
:
\"
tester4
\"
},
\"
what
\"
:[
\"
blog
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:{
\"
tester1
\"
:
\"
tester1
\"
},
\"
following
\"
:{
\"
gtg
\"
:
\"
gtg
\"
},
\"
what
\"
:[
\"
blog
\"
]}]"
}
},
{
...
...
@@ -385,7 +385,7 @@
"tester1"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:{
\"
tester3
\"
:
\"
tester4
\"
},
\"
what
\"
:[
\"
blog
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:{
\"
gtg
\"
:
\"
gtg
\"
},
\"
what
\"
:[
\"
blog
\"
]}]"
}
},
{
...
...
@@ -396,7 +396,7 @@
"tester1"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:[
\"
tester3
\"
, [
\"
tester4
\"
]],
\"
what
\"
:[
\"
blog
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:[
\"
tester3
\"
, [
\"
gtg
\"
]],
\"
what
\"
:[
\"
blog
\"
]}]"
}
},
{
...
...
@@ -407,7 +407,7 @@
"tester1"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:[
\"
tester1
\"
],
\"
following
\"
:[
\"
tester3
\"
, [
\"
tester4
\"
]],
\"
what
\"
:[
\"
blog
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:[
\"
tester1
\"
],
\"
following
\"
:[
\"
tester3
\"
, [
\"
gtg
\"
]],
\"
what
\"
:[
\"
blog
\"
]}]"
}
},
{
...
...
@@ -418,7 +418,7 @@
"[
\"
tester1
\"
]"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:[
\"
tester1
\"
],
\"
following
\"
:[
\"
tester3
\"
, {
\"
tester4
\"
:
\"
tester5
\"
}],
\"
what
\"
:[
\"
blog
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:[
\"
tester1
\"
],
\"
following
\"
:[
\"
tester3
\"
, {
\"
gtg
\"
:
\"
gtg
\"
}],
\"
what
\"
:[
\"
blog
\"
]}]"
}
},
{
...
...
@@ -429,7 +429,7 @@
"tester1"
],
"id"
:
"follow"
,
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:[
\"
tester3
\"
, {
\"
tester4
\"
:
\"
tester5
\"
}],
\"
what
\"
:[
\"
blog
\"
]}]"
"json"
:
"[
\"
follow
\"
,{
\"
follower
\"
:
\"
tester1
\"
,
\"
following
\"
:[
\"
tester3
\"
, {
\"
gtg
\"
:
\"
gtg
\"
}],
\"
what
\"
:[
\"
blog
\"
]}]"
}
}
]
...
...
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