fix write times

This commit is contained in:
2025-03-13 21:16:08 +01:00
parent 7f08d1972c
commit b3a429b3f2
3 changed files with 21 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import http
import logging
from datetime import datetime
from django.utils import timezone
from django.views.generic import View
from django.http import JsonResponse
@@ -12,6 +12,16 @@ logger = logging.getLogger(__name__)
from timer.models import TimeRecord
class HealthCheckApiView(View):
"""
View to check if the server is running
returns standard JsonResponse with status 'ok'
"""
@staticmethod
def get(request, *args, **kwargs):
return JsonResponse({"status": "ok"}, status=http.HTTPStatus.OK, safe=False)
class WriteTimeApiView(View):
"""
View to write time records
@@ -23,7 +33,7 @@ class WriteTimeApiView(View):
try:
# parse datetime from string of unix timestamp with milliseconds '1741169756.049847'
record_time = datetime.fromtimestamp(float(kwargs['time']))
record_time = timezone.make_aware(datetime.fromtimestamp(float(kwargs['time'])))
# create new TimeRecord object and save it to the database
TimeRecord(