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
ff9a7e7b
Commit
ff9a7e7b
authored
3 years ago
by
Benjamin Hättasch
Committed by
Nadja Geisler
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Implement violation check for multiple slots of the same AK at the same time
parent
f2bca549
No related branches found
No related tags found
2 merge requests
!100
Scheduling Constraints WIP WIP WIP
,
!99
Constraint Violation checking & visualization
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKScheduling/models.py
+27
-1
27 additions, 1 deletion
AKScheduling/models.py
with
27 additions
and
1 deletion
AKScheduling/models.py
+
27
−
1
View file @
ff9a7e7b
...
@@ -180,7 +180,7 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
...
@@ -180,7 +180,7 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
print
(
f
"
Multiple slots in room
{
instance
.
room
}
:
{
new_violations
}
"
)
print
(
f
"
Multiple slots in room
{
instance
.
room
}
:
{
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
slot
that was recently changed (important!)
existing_violations_to_check
=
list
(
instance
.
room
.
constraintviolation_set
.
filter
(
type
=
violation_type
))
existing_violations_to_check
=
list
(
instance
.
room
.
constraintviolation_set
.
filter
(
type
=
violation_type
))
print
(
existing_violations_to_check
)
print
(
existing_violations_to_check
)
update_constraint_violations
(
new_violations
,
existing_violations_to_check
)
update_constraint_violations
(
new_violations
,
existing_violations_to_check
)
...
@@ -189,6 +189,32 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
...
@@ -189,6 +189,32 @@ def akslot_changed_handler(sender, instance: AKSlot, **kwargs):
update_cv_reso_deadline_for_slot
(
instance
)
update_cv_reso_deadline_for_slot
(
instance
)
# == Check for two slots of the same AK at the same time (warning) ==
violation_type
=
ConstraintViolation
.
ViolationType
.
AK_SLOT_COLLISION
new_violations
=
[]
# For all other slots of this ak...
for
other_slot
in
instance
.
ak
.
akslot_set
.
filter
(
start__isnull
=
False
):
if
other_slot
!=
instance
:
# ... find overlapping slots...
if
instance
.
overlaps
(
other_slot
):
# ...and create a temporary violation if necessary...
c
=
ConstraintViolation
(
type
=
violation_type
,
level
=
ConstraintViolation
.
ViolationLevel
.
WARNING
,
event
=
event
,
)
c
.
aks_tmp
.
add
(
instance
.
ak
)
c
.
ak_slots_tmp
.
add
(
instance
)
c
.
ak_slots_tmp
.
add
(
other_slot
)
new_violations
.
append
(
c
)
# ... and compare to/update list of existing violations of this type
# belonging to the slot that was recently changed (important!)
existing_violations_to_check
=
list
(
instance
.
constraintviolation_set
.
filter
(
type
=
violation_type
))
update_constraint_violations
(
new_violations
,
existing_violations_to_check
)
@receiver
(
post_save
,
sender
=
Room
)
@receiver
(
post_save
,
sender
=
Room
)
def
room_changed_handler
(
sender
,
**
kwargs
):
def
room_changed_handler
(
sender
,
**
kwargs
):
...
...
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