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
4faeaf8d
Commit
4faeaf8d
authored
4 years ago
by
Mariusz Trela
Browse files
Options
Downloads
Patches
Plain Diff
Introduced `condenser_get_account_reputations` SQL function
parent
6619ece6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!456
Release candidate v1 24
,
!347
Refactoring + additional SQL functions
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hive/db/schema.py
+2
-1
2 additions, 1 deletion
hive/db/schema.py
hive/db/sql_scripts/condenser_get_account_reputations.sql
+28
-0
28 additions, 0 deletions
hive/db/sql_scripts/condenser_get_account_reputations.sql
hive/server/condenser_api/methods.py
+1
-8
1 addition, 8 deletions
hive/server/condenser_api/methods.py
with
31 additions
and
9 deletions
hive/db/schema.py
+
2
−
1
View file @
4faeaf8d
...
@@ -590,7 +590,8 @@ def setup(db):
...
@@ -590,7 +590,8 @@ def setup(db):
"
condenser_get_names_by_followers.sql
"
,
"
condenser_get_names_by_followers.sql
"
,
"
condenser_get_names_by_following.sql
"
,
"
condenser_get_names_by_following.sql
"
,
"
condenser_get_names_by_reblogged.sql
"
,
"
condenser_get_names_by_reblogged.sql
"
,
"
condenser_get_discussions_by_comments.sql
"
"
condenser_get_discussions_by_comments.sql
"
,
"
condenser_get_account_reputations.sql
"
]
]
from
os.path
import
dirname
,
realpath
from
os.path
import
dirname
,
realpath
...
...
This diff is collapsed.
Click to expand it.
hive/db/sql_scripts/condenser_get_account_reputations.sql
0 → 100644
+
28
−
0
View file @
4faeaf8d
DROP
FUNCTION
IF
EXISTS
condenser_get_account_reputations
;
CREATE
OR
REPLACE
FUNCTION
condenser_get_account_reputations
(
in
_account_lower_bound
VARCHAR
,
in
_without_lower_bound
BOOLEAN
,
in
_limit
INTEGER
)
RETURNS
TABLE
(
name
hive_accounts
.
name
%
TYPE
,
reputation
hive_accounts
.
reputation
%
TYPE
)
AS
$
function
$
DECLARE
BEGIN
RETURN
QUERY
SELECT
ha
.
name
,
ha
.
reputation
FROM
hive_accounts
ha
WHERE
_without_lower_bound
OR
(
ha
.
name
>=
_account_lower_bound
)
ORDER
BY
name
LIMIT
_limit
;
END
$
function
$
language
plpgsql
STABLE
;
This diff is collapsed.
Click to expand it.
hive/server/condenser_api/methods.py
+
1
−
8
View file @
4faeaf8d
...
@@ -92,15 +92,8 @@ async def get_account_reputations(context, account_lower_bound: str = None, limi
...
@@ -92,15 +92,8 @@ async def get_account_reputations(context, account_lower_bound: str = None, limi
async
def
_get_account_reputations_impl
(
db
,
fat_node_style
,
account_lower_bound
,
limit
):
async
def
_get_account_reputations_impl
(
db
,
fat_node_style
,
account_lower_bound
,
limit
):
"""
Enumerate account reputations.
"""
"""
Enumerate account reputations.
"""
limit
=
valid_limit
(
limit
,
1000
,
None
)
limit
=
valid_limit
(
limit
,
1000
,
None
)
seek
=
''
if
account_lower_bound
:
seek
=
"
WHERE name >= :start
"
sql
=
"""
SELECT name, reputation
FROM hive_accounts %s
ORDER BY name
LIMIT :limit
"""
%
seek
sql
=
"
SELECT * FROM condenser_get_account_reputations(
'
{}
'
, {}, {} )
"
.
format
(
account_lower_bound
,
account_lower_bound
is
None
,
limit
)
rows
=
await
db
.
query_all
(
sql
,
start
=
account_lower_bound
,
limit
=
limit
)
rows
=
await
db
.
query_all
(
sql
,
start
=
account_lower_bound
,
limit
=
limit
)
if
fat_node_style
:
if
fat_node_style
:
return
[
dict
(
account
=
r
[
0
],
reputation
=
r
[
1
])
for
r
in
rows
]
return
[
dict
(
account
=
r
[
0
],
reputation
=
r
[
1
])
for
r
in
rows
]
...
...
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