Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
network
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
9
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
funkwhale
network
Commits
a4c6a71a
Verified
Commit
a4c6a71a
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Can now limit the number of results returned by the /domains endpoint
parent
4277e58e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
funkwhale_network/routes.py
+6
-2
6 additions, 2 deletions
funkwhale_network/routes.py
tests/test_routes.py
+23
-0
23 additions, 0 deletions
tests/test_routes.py
with
29 additions
and
2 deletions
funkwhale_network/routes.py
+
6
−
2
View file @
a4c6a71a
...
...
@@ -21,6 +21,7 @@ domain_filters = {
"
open_registrations
"
:
fields
.
Bool
(),
"
anonymous_can_listen
"
:
fields
.
Bool
(),
"
federation_enabled
"
:
fields
.
Bool
(),
"
limit
"
:
fields
.
Integer
(),
}
...
...
@@ -48,11 +49,14 @@ async def index(request):
async
def
domains
(
request
):
if
request
.
method
==
"
GET
"
:
filters
=
await
parser
.
parse
(
domain_filters
,
request
)
limit
=
filters
.
pop
(
"
limit
"
,
0
)
rows
=
await
db
.
get_domains
(
request
[
"
conn
"
],
private
=
False
,
**
filters
)
total
=
len
(
rows
)
if
limit
:
rows
=
rows
[:
limit
]
payload
=
{
"
count
"
:
len
(
rows
)
,
"
count
"
:
total
,
"
previous
"
:
None
,
"
next
"
:
None
,
"
results
"
:
[
...
...
This diff is collapsed.
Click to expand it.
tests/test_routes.py
+
23
−
0
View file @
a4c6a71a
...
...
@@ -29,6 +29,29 @@ async def test_domains_get(db_conn, client, factories):
}
async
def
test_domains_get_page_size
(
db_conn
,
client
,
factories
):
checks
=
sorted
(
[
await
factories
[
"
Check
"
].
c
(
private
=
False
),
await
factories
[
"
Check
"
].
c
(
private
=
False
),
],
key
=
lambda
o
:
o
[
"
domain
"
],
)
for
check
in
checks
:
domain
=
await
db
.
get_domain
(
db_conn
,
check
[
"
domain
"
])
check
[
"
first_seen
"
]
=
domain
[
"
first_seen
"
]
check
[
"
node_name
"
]
=
domain
[
"
node_name
"
]
resp
=
await
client
.
get
(
"
/api/domains
"
,
params
=
{
"
limit
"
:
1
})
assert
resp
.
status
==
200
assert
await
resp
.
json
()
==
{
"
count
"
:
2
,
"
next
"
:
None
,
"
previous
"
:
None
,
"
results
"
:
[
serializers
.
serialize_domain_from_check
(
checks
[
0
])],
}
@pytest.mark.parametrize
(
"
field
"
,
[
"
up
"
,
"
open_registrations
"
,
"
anonymous_can_listen
"
,
"
federation_enabled
"
]
)
...
...
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