Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
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
Service Desk
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
KIF
AKPlanning
Commits
554b3871
Commit
554b3871
authored
3 years ago
by
Benjamin Hättasch
Browse files
Options
Downloads
Patches
Plain Diff
Fix constraint check for not-yet scheduled ak slots
parent
868a5198
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#22764
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKScheduling/models.py
+38
-36
38 additions, 36 deletions
AKScheduling/models.py
with
38 additions
and
36 deletions
AKScheduling/models.py
+
38
−
36
View file @
554b3871
...
@@ -268,29 +268,30 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
...
@@ -268,29 +268,30 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
violation_type
=
ConstraintViolation
.
ViolationType
.
OWNER_TWO_SLOTS
violation_type
=
ConstraintViolation
.
ViolationType
.
OWNER_TWO_SLOTS
new_violations
=
[]
new_violations
=
[]
# For all owners (after recent change)...
if
instance
.
start
:
for
owner
in
instance
.
ak
.
owners
.
all
():
# For all owners (after recent change)...
# ...find other slots that might be overlapping...
for
owner
in
instance
.
ak
.
owners
.
all
():
# ...find other slots that might be overlapping...
for
ak
in
owner
.
ak_set
.
all
():
for
ak
in
owner
.
ak_set
.
all
():
# ...find overlapping slots...
# ...find overlapping slots...
if
ak
!=
instance
.
ak
:
if
ak
!=
instance
.
ak
:
for
other_slot
in
ak
.
akslot_set
.
filter
(
start__isnull
=
False
):
for
other_slot
in
ak
.
akslot_set
.
filter
(
start__isnull
=
False
):
if
instance
.
overlaps
(
other_slot
):
if
instance
.
overlaps
(
other_slot
):
# ...and create a temporary violation if necessary...
# ...and create a temporary violation if necessary...
c
=
ConstraintViolation
(
c
=
ConstraintViolation
(
type
=
violation_type
,
type
=
violation_type
,
level
=
ConstraintViolation
.
ViolationLevel
.
VIOLATION
,
level
=
ConstraintViolation
.
ViolationLevel
.
VIOLATION
,
event
=
event
,
event
=
event
,
ak_owner
=
owner
ak_owner
=
owner
)
)
c
.
aks_tmp
.
add
(
instance
.
ak
)
c
.
aks_tmp
.
add
(
instance
.
ak
)
c
.
aks_tmp
.
add
(
other_slot
.
ak
)
c
.
aks_tmp
.
add
(
other_slot
.
ak
)
c
.
ak_slots_tmp
.
add
(
instance
)
c
.
ak_slots_tmp
.
add
(
instance
)
c
.
ak_slots_tmp
.
add
(
other_slot
)
c
.
ak_slots_tmp
.
add
(
other_slot
)
new_violations
.
append
(
c
)
new_violations
.
append
(
c
)
print
(
f
"
{
owner
}
has the following conflicts:
{
new_violations
}
"
)
print
(
f
"
{
owner
}
has the following conflicts:
{
new_violations
}
"
)
# ... and compare to/update list of existing violations of this type
# ... and compare to/update list of existing violations of this type
# belonging to the AK that was recently changed (important!)
# belonging to the AK that was recently changed (important!)
...
@@ -339,21 +340,22 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
...
@@ -339,21 +340,22 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
violation_type
=
ConstraintViolation
.
ViolationType
.
AK_SLOT_COLLISION
violation_type
=
ConstraintViolation
.
ViolationType
.
AK_SLOT_COLLISION
new_violations
=
[]
new_violations
=
[]
# For all other slots of this ak...
if
instance
.
start
:
for
other_slot
in
instance
.
ak
.
akslot_set
.
filter
(
start__isnull
=
False
):
# For all other slots of this ak...
if
other_slot
!=
instance
:
for
other_slot
in
instance
.
ak
.
akslot_set
.
filter
(
start__isnull
=
False
):
# ... find overlapping slots...
if
other_slot
!=
instance
:
if
instance
.
overlaps
(
other_slot
):
# ... find overlapping slots...
# ...and create a temporary violation if necessary...
if
instance
.
overlaps
(
other_slot
):
c
=
ConstraintViolation
(
# ...and create a temporary violation if necessary...
type
=
violation_type
,
c
=
ConstraintViolation
(
level
=
ConstraintViolation
.
ViolationLevel
.
WARNING
,
type
=
violation_type
,
event
=
event
,
level
=
ConstraintViolation
.
ViolationLevel
.
WARNING
,
)
event
=
event
,
c
.
aks_tmp
.
add
(
instance
.
ak
)
)
c
.
ak_slots_tmp
.
add
(
instance
)
c
.
aks_tmp
.
add
(
instance
.
ak
)
c
.
ak_slots_tmp
.
add
(
other_slot
)
c
.
ak_slots_tmp
.
add
(
instance
)
new_violations
.
append
(
c
)
c
.
ak_slots_tmp
.
add
(
other_slot
)
new_violations
.
append
(
c
)
# ... and compare to/update list of existing violations of this type
# ... and compare to/update list of existing violations of this type
# belonging to the slot that was recently changed (important!)
# belonging to the slot that was recently changed (important!)
...
...
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