SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
SciPost
SciPost
Commits
4e3f06d3
Commit
4e3f06d3
authored
3 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
optimize task queries with prefetch
parent
172b4047
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost_django/tasks/tasks/task_kinds.py
+19
-12
19 additions, 12 deletions
scipost_django/tasks/tasks/task_kinds.py
with
19 additions
and
12 deletions
scipost_django/tasks/tasks/task_kinds.py
+
19
−
12
View file @
4e3f06d3
...
@@ -87,6 +87,7 @@ class ScheduleSubsidyPayments(TaskKind):
...
@@ -87,6 +87,7 @@ class ScheduleSubsidyPayments(TaskKind):
Q
(
collective__isnull
=
True
)
Q
(
collective__isnull
=
True
)
&
(
Q
(
schedule_blank
=
True
)
|
Q
(
schedule_complete
=
False
))
&
(
Q
(
schedule_blank
=
True
)
|
Q
(
schedule_complete
=
False
))
)
)
.
prefetch_related
(
"
organization
"
)
)
)
...
@@ -131,6 +132,7 @@ class ScheduleSubsidyCollectivePayments(TaskKind):
...
@@ -131,6 +132,7 @@ class ScheduleSubsidyCollectivePayments(TaskKind):
),
),
)
)
.
filter
(
Q
(
schedule_complete
=
False
))
.
filter
(
Q
(
schedule_complete
=
False
))
.
prefetch_related
(
"
coordinator
"
)
)
)
...
@@ -173,6 +175,7 @@ class SendSubsidyInvoiceTask(TaskKind):
...
@@ -173,6 +175,7 @@ class SendSubsidyInvoiceTask(TaskKind):
Q
(
due_date__isnull
=
False
)
Q
(
due_date__isnull
=
False
)
&
(
Q
(
status
=
SUBSIDY_PROMISED
)
|
Q
(
status
=
SUBSIDY_UPTODATE
))
&
(
Q
(
status
=
SUBSIDY_PROMISED
)
|
Q
(
status
=
SUBSIDY_UPTODATE
))
)
)
.
prefetch_related
(
"
organization
"
)
)
)
...
@@ -216,6 +219,7 @@ class CheckSubsidyPaymentTask(TaskKind):
...
@@ -216,6 +219,7 @@ class CheckSubsidyPaymentTask(TaskKind):
),
),
)
)
.
filter
(
Q
(
status
=
SUBSIDY_INVOICED
))
.
filter
(
Q
(
status
=
SUBSIDY_INVOICED
))
.
prefetch_related
(
"
organization
"
)
)
)
...
@@ -283,9 +287,11 @@ class VetCommentTask(TaskKind):
...
@@ -283,9 +287,11 @@ class VetCommentTask(TaskKind):
@classmethod
@classmethod
def
get_queryset
(
cls
)
->
"
QuerySet
"
:
def
get_queryset
(
cls
)
->
"
QuerySet
"
:
return
get_objects_for_user
(
return
(
cls
.
user
,
"
comments.can_vet_comments
"
get_objects_for_user
(
cls
.
user
,
"
comments.can_vet_comments
"
)
).
awaiting_vetting
()
.
awaiting_vetting
()
.
prefetch_related
(
"
author__user
"
)
)
class
VetReportTask
(
TaskKind
):
class
VetReportTask
(
TaskKind
):
...
@@ -320,19 +326,20 @@ class VetReportTask(TaskKind):
...
@@ -320,19 +326,20 @@ class VetReportTask(TaskKind):
if
cls
.
user
is
None
:
if
cls
.
user
is
None
:
return
Report
.
objects
.
none
()
return
Report
.
objects
.
none
()
if
cls
.
user
.
has_perm
(
"
scipost.can_vet_submitted_reports
"
):
qs
=
Report
.
objects
.
all
()
return
Report
.
objects
.
awaiting_vetting
()
if
not
cls
.
user
.
has_perm
(
"
scipost.can_vet_submitted_reports
"
):
qs
=
qs
.
filter
(
return
Report
.
objects
.
filter
(
submission__in
=
Submission
.
objects
.
in_pool_filter_for_eic
(
submission__in
=
Submission
.
objects
.
in_pool_filter_for_eic
(
cls
.
user
,
latest
=
False
,
historical
=
True
cls
.
user
,
latest
=
False
,
historical
=
True
)
)
)
).
awaiting_vetting
()
return
qs
.
awaiting_vetting
().
prefetch_related
(
"
submission
"
)
class
SelectRefereeingCycleTask
(
TaskKind
):
class
SelectRefereeingCycleTask
(
TaskKind
):
name
=
"
Select Refereeing Cycle
"
name
=
"
Select Refereeing Cycle
"
task_title
=
"
Select Refereeing Cycle for {object}
"
task_title
=
"
Select Refereeing Cycle for {object
.title
}
"
description
=
"
Select the refereeing cycle for a submission.
"
description
=
"
Select the refereeing cycle for a submission.
"
actions
=
[
actions
=
[
lambda
task
:
ViewAction
(
lambda
task
:
ViewAction
(
...
@@ -361,5 +368,5 @@ class SelectRefereeingCycleTask(TaskKind):
...
@@ -361,5 +368,5 @@ class SelectRefereeingCycleTask(TaskKind):
return
Submission
.
objects
.
filter
(
return
Submission
.
objects
.
filter
(
editor_in_charge
=
cls
.
user
.
contributor
,
editor_in_charge
=
cls
.
user
.
contributor
,
refereeing_cycle__isnull
=
Tru
e
,
refereeing_cycle__isnull
=
Fals
e
,
)
)
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