Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
a07f4204
Commit
a07f4204
authored
2 years ago
by
Valentin Rigal
Browse files
Options
Downloads
Patches
Plain Diff
Drop Ponos non Postgres DB support
parent
fca6175b
No related branches found
No related tags found
1 merge request
!1908
Drop Ponos non Postgres DB support
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/ponos/managers.py
+15
-27
15 additions, 27 deletions
arkindex/ponos/managers.py
with
15 additions
and
27 deletions
arkindex/ponos/managers.py
+
15
−
27
View file @
a07f4204
from
django.db
import
connections
from
django.db.models
import
Manager
...
...
@@ -6,31 +5,20 @@ class TaskManager(Manager):
def
parents
(
self
,
task
):
"""
List all tasks that a task depends on, directly or not.
When using a PostgreSQL database, this will use a recursive query.
This falls back to a recursive generator on other databases.
A PostgreSQL recursive query is used for better performances.
"""
if
connections
[
self
.
db
].
vendor
==
"
postgresql
"
:
return
self
.
raw
(
"""
with recursive parents(id) as (
select to_task_id
from ponos_task_parents j
where j.from_task_id = %s
union all
select j.to_task_id
from ponos_task_parents as j, parents
where j.from_task_id = parents.id
)
select distinct * from parents
"""
,
[
task
.
id
],
return
self
.
raw
(
"""
with recursive parents(id) as (
select to_task_id
from ponos_task_parents j
where j.from_task_id = %s
union all
select j.to_task_id
from ponos_task_parents as j, parents
where j.from_task_id = parents.id
)
else
:
def
_parents_python
(
task
):
yield
from
task
.
parents
.
all
()
for
parent
in
task
.
parents
.
all
():
yield
from
_parents_python
(
parent
)
return
_parents_python
(
task
)
select distinct * from parents
"""
,
[
task
.
id
],
)
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