Skip to content

Commit

Permalink
serialize duration as float
Browse files Browse the repository at this point in the history
  • Loading branch information
jeriox committed Mar 16, 2024
1 parent 19e6064 commit 3ce5d3a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ephios/api/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

class ChoiceDisplayField(ChoiceField):
def to_representation(self, value):
return {"value": value, "readable_text": self.choices[value]}
return {"value": value, "label": self.choices[value]}
2 changes: 1 addition & 1 deletion ephios/api/views/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ def build_unknown_field(self, field_name, model_class):
return super().build_unknown_field(field_name, model_class)

def get_duration(self, obj):
return obj.end_time - obj.start_time
return float((obj.end_time - obj.start_time).total_seconds())

0 comments on commit 3ce5d3a

Please sign in to comment.