Skip to content

[FIX] beesdoo_shift: forbid illegal hour#292

Open
tfrancoi wants to merge 1 commit into12.0from
12.0-shift-constraint
Open

[FIX] beesdoo_shift: forbid illegal hour#292
tfrancoi wants to merge 1 commit into12.0from
12.0-shift-constraint

Conversation

@tfrancoi
Copy link
Copy Markdown
Contributor

It was possible to encode shift that start at negative hour
or hour bigger then 24. Of course this lead to some
error at the moment we generate the planning for a given date

  • Add a constraint on start_time and end_time
  • Fix onchange on duration: duration was not computed properly
    when the start or end time was 00:00

@tfrancoi tfrancoi added the Polln label Feb 24, 2022
@tfrancoi tfrancoi mentioned this pull request Feb 24, 2022
@robinkeunen robinkeunen force-pushed the 12.0-shift-constraint branch from 88611e3 to 61a83e4 Compare February 24, 2022 16:05
It was possible to encode shift that start at negative hour
or hour bigger then 24. Of course this lead to some
error at the moment we generate the planning for a given date

- Add a constraint on start_time and end_time
- Fix onchange on duration: duration was not computed properly
when the start or end time was 00:00
@robinkeunen robinkeunen force-pushed the 12.0-shift-constraint branch from 61a83e4 to 6a36584 Compare March 9, 2022 17:28
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #292 (6a36584) into 12.0 (fa7306c) will decrease coverage by 0.00%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             12.0     #292      +/-   ##
==========================================
- Coverage   68.53%   68.53%   -0.01%     
==========================================
  Files         107      107              
  Lines        3366     3369       +3     
  Branches      589      590       +1     
==========================================
+ Hits         2307     2309       +2     
  Misses        951      951              
- Partials      108      109       +1     
Impacted Files Coverage Δ
beesdoo_shift/models/planning.py 82.05% <40.00%> (-0.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa7306c...6a36584. Read the comment docs.

def _get_duration(self):
if self.start_time and self.end_time:
self.duration = self.end_time - self.start_time
self.duration = (self.end_time or 0.0) - (self.start_time or 0.0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather return False when start_time or end_time instead of these weird values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.duration = (self.end_time or 0.0) - (self.start_time or 0.0)
if self.start_time and self.end_time:
self.duration = self.end_time - self.start_time
else:
self.duration = False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants