Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Official
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
0inraMfauri
Official
Commits
666ef21c
Verified
Commit
666ef21c
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Prevent conflicts with filtering versions by avoiding union operations before
parent
c6463161
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.rst
+1
-0
1 addition, 0 deletions
CHANGELOG.rst
aleksis/apps/untis/commands.py
+16
-3
16 additions, 3 deletions
aleksis/apps/untis/commands.py
aleksis/apps/untis/util/mysql/importers/terms.py
+7
-2
7 additions, 2 deletions
aleksis/apps/untis/util/mysql/importers/terms.py
with
24 additions
and
5 deletions
CHANGELOG.rst
+
1
−
0
View file @
666ef21c
...
@@ -29,6 +29,7 @@ Fixed
...
@@ -29,6 +29,7 @@ Fixed
* Search course groups not only by parent groups and subject, but also take
* Search course groups not only by parent groups and subject, but also take
the teachers (group owners) into account
the teachers (group owners) into account
* Don't recreate lesson periods if they change, but just update them.
* Don't recreate lesson periods if they change, but just update them.
* Import failed if there were multiple versions for a term in the future.
`2.1.3`_ - 2022-02-06
`2.1.3`_ - 2022-02-06
---------------------
---------------------
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/commands.py
+
16
−
3
View file @
666ef21c
from
typing
import
Optional
from
typing
import
Optional
from
django.db.models
import
QuerySet
from
django.db.models
import
Q
,
QuerySet
from
django.utils.functional
import
classproperty
from
django.utils.functional
import
classproperty
from
aleksis.apps.untis.util.mysql.importers.terms
import
(
from
aleksis.apps.untis.util.mysql.importers.terms
import
(
get_future_terms_for_date
,
get_future_terms_for_date
,
get_terms
,
get_terms_for_date
,
get_terms_for_date
,
)
)
...
@@ -72,7 +73,12 @@ class CurrentNextImportCommand(ImportCommand):
...
@@ -72,7 +73,12 @@ class CurrentNextImportCommand(ImportCommand):
terms
=
get_terms_for_date
()
terms
=
get_terms_for_date
()
future_terms
=
get_future_terms_for_date
()
future_terms
=
get_future_terms_for_date
()
if
future_terms
.
exists
():
if
future_terms
.
exists
():
terms
=
terms
.
union
(
future_terms
[
0
:
1
])
future_term
=
future_terms
.
first
()
terms
=
(
get_terms
()
.
filter
(
Q
(
pk__in
=
terms
.
values_list
(
"
pk
"
,
flat
=
True
))
|
Q
(
pk
=
future_term
.
pk
))
.
distinct
()
)
return
terms
return
terms
...
@@ -85,7 +91,14 @@ class CurrentFutureImportCommand(ImportCommand):
...
@@ -85,7 +91,14 @@ class CurrentFutureImportCommand(ImportCommand):
def
get_terms
(
cls
)
->
Optional
[
QuerySet
]:
def
get_terms
(
cls
)
->
Optional
[
QuerySet
]:
terms
=
get_terms_for_date
()
terms
=
get_terms_for_date
()
future_terms
=
get_future_terms_for_date
()
future_terms
=
get_future_terms_for_date
()
terms
=
terms
.
union
(
future_terms
)
terms
=
(
get_terms
()
.
filter
(
Q
(
pk__in
=
terms
.
values_list
(
"
pk
"
,
flat
=
True
))
|
Q
(
pk__in
=
future_terms
.
values_list
(
"
pk
"
,
flat
=
True
))
)
.
distinct
()
)
return
terms
return
terms
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/util/mysql/importers/terms.py
+
7
−
2
View file @
666ef21c
...
@@ -19,12 +19,17 @@ from aleksis.core import models as core_models
...
@@ -19,12 +19,17 @@ from aleksis.core import models as core_models
from
....
import
models
as
mysql_models
from
....
import
models
as
mysql_models
def
get_terms
()
->
QuerySet
:
"""
Get all terms.
"""
return
run_using
(
mysql_models
.
Terms
.
objects
).
order_by
(
"
datefrom
"
)
def
get_terms_for_date
(
for_date
:
Optional
[
date
]
=
None
)
->
QuerySet
:
def
get_terms_for_date
(
for_date
:
Optional
[
date
]
=
None
)
->
QuerySet
:
"""
Get term queryset with term valid for the provided date.
"""
"""
Get term queryset with term valid for the provided date.
"""
if
not
for_date
:
if
not
for_date
:
for_date
=
timezone
.
now
().
date
()
for_date
=
timezone
.
now
().
date
()
qs
=
run_using
(
mysql_models
.
Terms
.
objects
).
filter
(
qs
=
get_terms
(
).
filter
(
datefrom__lte
=
date_to_untis_date
(
for_date
),
datefrom__lte
=
date_to_untis_date
(
for_date
),
dateto__gte
=
date_to_untis_date
(
for_date
),
dateto__gte
=
date_to_untis_date
(
for_date
),
)
)
...
@@ -37,7 +42,7 @@ def get_future_terms_for_date(for_date: Optional[date] = None) -> QuerySet:
...
@@ -37,7 +42,7 @@ def get_future_terms_for_date(for_date: Optional[date] = None) -> QuerySet:
if
not
for_date
:
if
not
for_date
:
for_date
=
timezone
.
now
().
date
()
for_date
=
timezone
.
now
().
date
()
qs
=
run_using
(
mysql_models
.
Terms
.
objects
).
filter
(
qs
=
get_terms
(
).
filter
(
datefrom__gt
=
date_to_untis_date
(
for_date
),
datefrom__gt
=
date_to_untis_date
(
for_date
),
)
)
...
...
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