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
3dc519ea
Commit
3dc519ea
authored
2 months ago
by
Felix Blanke
Browse files
Options
Downloads
Patches
Plain Diff
Encapsulate discretization in Event::discretize_timeslots
parent
aee5627c
No related branches found
No related tags found
1 merge request
!7
Encapsulate discretization in Event::discretize_timeslots
Pipeline
#269127
failed
2 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AKModel/models.py
+8
-1
8 additions, 1 deletion
AKModel/models.py
AKModel/views/ak.py
+1
-5
1 addition, 5 deletions
AKModel/views/ak.py
with
9 additions
and
6 deletions
AKModel/models.py
+
8
−
1
View file @
3dc519ea
...
...
@@ -382,6 +382,13 @@ class Event(models.Model):
constraints
=
category_constraints
,
)
def
discretize_timeslots
(
self
,
*
,
slots_in_an_hour
:
float
=
1.0
)
->
Iterable
[
TimeslotBlock
]:
if
DefaultSlot
.
objects
.
filter
(
event
=
self
.
event
).
exists
():
# discretize default slots if they exists
yield
from
merge_blocks
(
self
.
default_time_slots
(
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
))
else
:
yield
from
self
.
uniform_time_slots
(
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
)
def
schedule_from_json
(
self
,
schedule
:
str
)
->
None
:
"""
Load AK schedule from a json string.
...
...
@@ -396,7 +403,7 @@ class Event(models.Model):
timeslot_dict
=
{
timeslot
.
idx
:
timeslot
for
block
in
merge_blocks
(
self
.
default
_time
_
slots
(
slots_in_an_hour
=
slots_in_an_hour
)
)
for
block
in
self
.
discretize
_timeslots
(
slots_in_an_hour
=
slots_in_an_hour
)
for
timeslot
in
block
}
...
...
This diff is collapsed.
Click to expand it.
AKModel/views/ak.py
+
1
−
5
View file @
3dc519ea
...
...
@@ -114,11 +114,7 @@ class AKJSONExportView(AdminViewMixin, FilterByEventSlugMixin, ListView):
if
(
values
:
=
AKSlot
.
objects
.
select_related
().
filter
(
ak__pk
=
ak_id
,
fixed
=
True
)).
exists
()
}
if
DefaultSlot
.
objects
.
filter
(
event
=
self
.
event
).
exists
():
# discretize default slots if they exists
blocks
=
merge_blocks
(
self
.
event
.
default_time_slots
(
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
))
else
:
blocks
=
self
.
event
.
uniform_time_slots
(
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
)
blocks
=
self
.
event
.
discretize_timeslots
(
slots_in_an_hour
=
SLOTS_IN_AN_HOUR
)
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