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
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
Felix Blanke
AKPlanning
Commits
74ac670a
Commit
74ac670a
authored
3 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Add export slot length to event
parent
ab8a0014
No related branches found
No related tags found
1 merge request
!13
Feature: Add export discretization length for JSON-export
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
AKModel/migrations/0061_event_export_slot.py
+24
-0
24 additions, 0 deletions
AKModel/migrations/0061_event_export_slot.py
AKModel/models.py
+13
-5
13 additions, 5 deletions
AKModel/models.py
AKModel/views/ak.py
+2
-8
2 additions, 8 deletions
AKModel/views/ak.py
with
39 additions
and
13 deletions
AKModel/migrations/0061_event_export_slot.py
0 → 100644
+
24
−
0
View file @
74ac670a
# Generated by Django 4.2.13 on 2025-02-06 16:09
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
"
AKModel
"
,
"
0060_orga_message_resolved
"
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
"
event
"
,
name
=
"
export_slot
"
,
field
=
models
.
DecimalField
(
decimal_places
=
2
,
default
=
1
,
help_text
=
"
Slot duration in hours that is used in the timeslot discretization, when this event is exported for the solver.
"
,
max_digits
=
4
,
verbose_name
=
"
Export Slot Length
"
,
),
),
]
This diff is collapsed.
Click to expand it.
AKModel/models.py
+
13
−
5
View file @
74ac670a
...
...
@@ -151,6 +151,12 @@ class Event(models.Model):
wiki_export_template_name
=
models
.
CharField
(
verbose_name
=
_
(
"
Wiki Export Template Name
"
),
blank
=
True
,
max_length
=
50
)
default_slot
=
models
.
DecimalField
(
max_digits
=
4
,
decimal_places
=
2
,
default
=
2
,
verbose_name
=
_
(
'
Default Slot Length
'
),
help_text
=
_
(
'
Default length in hours that is assumed for AKs in this event.
'
))
export_slot
=
models
.
DecimalField
(
max_digits
=
4
,
decimal_places
=
2
,
default
=
1
,
verbose_name
=
_
(
'
Export Slot Length
'
),
help_text
=
_
(
'
Slot duration in hours that is used in the timeslot discretization, when this event
'
'
is exported for the solver.
'
))
contact_email
=
models
.
EmailField
(
verbose_name
=
_
(
"
Contact email address
"
),
blank
=
True
,
help_text
=
_
(
"
An email address that is displayed on every page
"
...
...
@@ -336,7 +342,7 @@ class Event(models.Model):
return
slot_index
def
uniform_time_slots
(
self
,
*
,
slots_in_an_hour
:
float
=
1.0
)
->
Iterable
[
TimeslotBlock
]:
def
uniform_time_slots
(
self
,
*
,
slots_in_an_hour
:
float
)
->
Iterable
[
TimeslotBlock
]:
"""
Uniformly discretize the entire event into blocks of timeslots.
Discretizes entire event uniformly. May not necessarily result in a single block
...
...
@@ -358,7 +364,7 @@ class Event(models.Model):
constraints
=
all_category_constraints
,
)
def
default_time_slots
(
self
,
*
,
slots_in_an_hour
:
float
=
1.0
)
->
Iterable
[
TimeslotBlock
]:
def
default_time_slots
(
self
,
*
,
slots_in_an_hour
:
float
)
->
Iterable
[
TimeslotBlock
]:
"""
Discretize all default slots into blocks of timeslots.
In the discretization each default slot corresponds to one block.
...
...
@@ -384,7 +390,7 @@ class Event(models.Model):
constraints
=
category_constraints
,
)
def
discretize_timeslots
(
self
,
*
,
slots_in_an_hour
:
float
=
1.0
)
->
Iterable
[
TimeslotBlock
]:
def
discretize_timeslots
(
self
,
*
,
slots_in_an_hour
:
float
|
None
=
None
)
->
Iterable
[
TimeslotBlock
]:
""""
Choose discretization scheme.
Uses default_time_slots if the event has any DefaultSlot, otherwise uniform_time_slots.
...
...
@@ -395,6 +401,9 @@ class Event(models.Model):
:ytype: list of TimeslotBlock
"""
if
slots_in_an_hour
is
None
:
slots_in_an_hour
=
float
(
self
.
export_slot
)
if
DefaultSlot
.
objects
.
filter
(
event
=
self
).
exists
():
# discretize default slots if they exists
yield
from
merge_blocks
(
self
.
default_time_slots
(
slots_in_an_hour
=
slots_in_an_hour
))
...
...
@@ -1007,10 +1016,9 @@ class AKSlot(models.Model):
ceil_offet_eps
=
decimal
.
Decimal
(
1e-4
)
# self.slots_in_an_hour is set in AKJSONExportView
data
=
{
"
id
"
:
str
(
self
.
pk
),
"
duration
"
:
math
.
ceil
(
self
.
duration
*
self
.
slots_in_an_hour
-
ceil_offet_eps
),
"
duration
"
:
math
.
ceil
(
self
.
duration
*
self
.
event
.
export_slot
-
ceil_offet_eps
),
"
properties
"
:
{
"
conflicts
"
:
[
str
(
conflict
.
pk
)
for
conflict
in
conflict_slots
.
all
()]
...
...
This diff is collapsed.
Click to expand it.
AKModel/views/ak.py
+
2
−
8
View file @
74ac670a
...
...
@@ -91,17 +91,11 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
rooms
=
Room
.
objects
.
filter
(
event
=
self
.
event
)
context
[
"
rooms
"
]
=
rooms
# TODO: Configure magic number in event
SLOTS_IN_AN_HOUR
=
1
timeslots
=
{
"
info
"
:
{
"
duration
"
:
(
1.0
/
SLOTS_IN_AN_HOUR
),
},
"
info
"
:
{
"
duration
"
:
(
1.0
/
float
(
self
.
event
.
export_slot
)
),
},
"
blocks
"
:
[],
}
for
slot
in
context
[
"
slots
"
]:
slot
.
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
ak_availabilities
=
{
ak
.
pk
:
Availability
.
union
(
ak
.
availabilities
.
all
())
for
ak
in
AK
.
objects
.
filter
(
event
=
self
.
event
).
all
()
...
...
@@ -115,7 +109,7 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
for
person
in
AKOwner
.
objects
.
filter
(
event
=
self
.
event
)
}
blocks
=
self
.
event
.
discretize_timeslots
(
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
)
blocks
=
self
.
event
.
discretize_timeslots
()
for
block
in
blocks
:
current_block
=
[]
...
...
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