Skip to content
Snippets Groups Projects
Commit bb1179c7 authored by Lorenzo Conti's avatar Lorenzo Conti
Browse files

Merge branch 'feature/duration-rounding-strategy' into 'main'

Rounding strategy for slot duration at JSON export

Closes #16

See merge request !6
parents e0801c1f 9301ef7a
Branches
Tags
2 merge requests!17Add view to clear schedule,!6Rounding strategy for slot duration at JSON export
Pipeline #269213 passed
import decimal
import itertools
import json
import math
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Iterable, Generator
......@@ -951,10 +953,12 @@ class AKSlot(models.Model):
return []
return [f"availability-person-{owner.pk}"]
ceil_offet_eps = decimal.Decimal(1e-4)
# self.slots_in_an_hour is set in AKJSONExportView
data = {
"id": str(self.pk),
"duration": round(self.duration * self.slots_in_an_hour),
"duration": math.ceil(self.duration * self.slots_in_an_hour - ceil_offet_eps),
"properties": {},
"room_constraints": [constraint.name
for constraint in self.ak.requirements.all()],
......@@ -965,6 +969,7 @@ class AKSlot(models.Model):
for owner in self.ak.owners.all()]),
"description": self.ak.description,
"reso": self.ak.reso,
"duration_in_hours": float(self.duration),
},
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment