update docker deployment and changing seed kandang name
This commit is contained in:
1 parent
76f4d0106a
commit
74dd3faf60
40 files changed
+1253
-122
No files matched your search
@@ -28,9 +28,25 @@ from apps.operations.serializers import (
|
||||
ManualInputSerializer,
|
||||
)
|
||||
from apps.operations.services.karung_web import KarungWebError, request_karung
|
||||
from apps.operations.services.visibility import dashboard_publish_time, visible_through_date
|
||||
|
||||
READ_ACTIONS = frozenset({"list", "retrieve", "latest_average", "latest", "dates"})
|
||||
|
||||
|
||||
class CycleScopedViewSet(viewsets.ModelViewSet):
|
||||
class VisibilityFilteredMixin:
|
||||
visibility_date_field = "date"
|
||||
|
||||
def applies_visibility_filter(self) -> bool:
|
||||
return getattr(self, "action", None) in READ_ACTIONS
|
||||
|
||||
def filter_visible_through(self, qs):
|
||||
if not self.applies_visibility_filter():
|
||||
return qs
|
||||
cutoff = visible_through_date()
|
||||
return qs.filter(**{f"{self.visibility_date_field}__lte": cutoff})
|
||||
|
||||
|
||||
class CycleScopedViewSet(VisibilityFilteredMixin, viewsets.ModelViewSet):
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset()
|
||||
params = self.request.query_params
|
||||
@@ -40,7 +56,7 @@ class CycleScopedViewSet(viewsets.ModelViewSet):
|
||||
qs = qs.filter(cycle__flocks__flock_id=params["flock_id"]).distinct()
|
||||
if params.get("date"):
|
||||
qs = qs.filter(date=params["date"])
|
||||
return qs
|
||||
return self.filter_visible_through(qs)
|
||||
|
||||
|
||||
class KPIViewSet(CycleScopedViewSet):
|
||||
@@ -126,6 +142,7 @@ class FeedSacksViewSet(CycleScopedViewSet):
|
||||
|
||||
|
||||
class IotPanelViewSet(viewsets.ModelViewSet):
|
||||
"""IoT panel is real-time — not subject to the 17:00 dashboard publish cutoff."""
|
||||
queryset = IotPanel.objects.select_related("flock", "flock__cycle").all()
|
||||
serializer_class = IotPanelSerializer
|
||||
|
||||
@@ -166,9 +183,14 @@ class HealthView(APIView):
|
||||
authentication_classes = []
|
||||
|
||||
def get(self, request):
|
||||
cutoff = visible_through_date()
|
||||
publish = dashboard_publish_time()
|
||||
payload = {
|
||||
"status": "ok",
|
||||
"service": "newdashboard-api",
|
||||
"karung_web_admin_base_configured": bool(settings.KARUNG_WEB_ADMIN_BASE_URL),
|
||||
"visible_through_date": cutoff.isoformat(),
|
||||
"dashboard_publish_time": publish.strftime("%H:%M"),
|
||||
"dashboard_timezone": settings.TIME_ZONE,
|
||||
}
|
||||
return Response(payload)
|
||||
Reference in new issue
Block a user