Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
IGWN Computing and Software
GraceDB
GraceDB Server
Commits
920dbe16
Commit
920dbe16
authored
4 months ago
by
Alexander Pace
Browse files
Options
Downloads
Patches
Plain Diff
improve gwtc query performance
parent
50e8ab4f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!247
improve gwtc query performance
Pipeline
#681337
passed
4 months ago
Stage: test
Stage: branch
Stage: latest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/settings/base.py
+1
-1
1 addition, 1 deletion
config/settings/base.py
gracedb/api/v1/gwtc/viewsets.py
+17
-8
17 additions, 8 deletions
gracedb/api/v1/gwtc/viewsets.py
with
18 additions
and
9 deletions
config/settings/base.py
+
1
−
1
View file @
920dbe16
...
...
@@ -463,7 +463,7 @@ REST_FRAMEWORK = {
'
ALLOWED_VERSIONS
'
:
[
'
default
'
,
'
v1
'
,
'
v2
'
],
'
DEFAULT_PAGINATION_CLASS
'
:
'
rest_framework.pagination.LimitOffsetPagination
'
,
'
PAGE_SIZE
'
:
1
e7
,
'
PAGE_SIZE
'
:
1
00
,
'
DEFAULT_THROTTLE_CLASSES
'
:
(
'
api.throttling.BurstAnonRateThrottle
'
,
),
...
...
This diff is collapsed.
Click to expand it.
gracedb/api/v1/gwtc/viewsets.py
+
17
−
8
View file @
920dbe16
...
...
@@ -8,7 +8,7 @@ from django.shortcuts import get_object_or_404
from
guardian.shortcuts
import
get_objects_for_user
from
rest_framework
import
mixins
,
parsers
,
permissions
,
serializers
,
status
,
\
viewsets
viewsets
,
pagination
from
rest_framework.decorators
import
action
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
...
...
@@ -18,10 +18,18 @@ from gwtc.models import gwtc_catalog, gwtc_gevent, gwtc_superevent
from
.serializers
import
gwtc_serializer
from
.permissions
import
gwtc_model_permissions
class
custom_gwtc_paginator
(
pagination
.
LimitOffsetPagination
):
default_limit
=
10
limit_query_param
=
'
count
'
offset_query_param
=
'
start
'
class
gwtc_viewset
(
SafeCreateMixin
,
InheritDefaultPermissionsMixin
,
viewsets
.
ModelViewSet
):
queryset
=
gwtc_catalog
.
objects
.
all
()
serializer_class
=
gwtc_serializer
pagination_class
=
custom_gwtc_paginator
permission_classes
=
(
gwtc_model_permissions
,
)
# This function gets called for 'list' methods, and returns a queryset. This
...
...
@@ -32,14 +40,15 @@ class gwtc_viewset(SafeCreateMixin, InheritDefaultPermissionsMixin,
selected_number
=
self
.
kwargs
.
get
(
'
number
'
)
selected_version
=
self
.
kwargs
.
get
(
'
version
'
)
# if no catalog number is specified, return all the catalogs
if
not
selected_number
:
return
self
.
queryset
else
:
# if the user specified a number, but not a version, return all the versions
# of that catalog number
# if the catalog number is specified, then return the filtered queryset
if
selected_number
:
self
.
queryset
=
self
.
queryset
.
filter
(
number
=
selected_number
)
return
self
.
queryset
.
filter
(
number
=
selected_number
)
return
self
.
queryset
.
prefetch_related
(
'
gwtc_superevent_set
'
,
'
gwtc_superevent_set__superevent
'
,
'
gwtc_superevent_set__gwtc_gevent_set
'
,
'
gwtc_superevent_set__gwtc_gevent_set__gevent
'
,
'
gwtc_superevent_set__gwtc_gevent_set__gevent__pipeline
'
)
# This function gets called for 'list' methods, and returns a queryset. This
# is called for `GET` requests to /api/gwtc/{number}/{version}
...
...
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