Skip to content

Commit e7efa93

Browse files
authored
DBC22-6336: added winter time start and end to filter hef data (#1317)
DBC22-6336: got now time per request DBC22-6336: keep hef data less than 24 hours for forecast
1 parent 80167ba commit e7efa93

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/backend/apps/weather/views.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from datetime import datetime, timedelta
2+
from django.utils import timezone
3+
4+
15
from apps.shared.enums import CacheKey, CacheTimeout
26
from apps.shared.views import CachedListModelMixin
37
from apps.weather.models import CurrentWeather, HighElevationForecast, RegionalWeather
@@ -28,10 +32,17 @@ class CurrentWeatherViewSet(CurrentWeatherAPI, viewsets.ReadOnlyModelViewSet):
2832
pass
2933

3034
class HighElevationAPI(CachedListModelMixin):
31-
queryset = HighElevationForecast.objects.all()
3235
serializer_class = HighElevationForecastSerializer
3336
cache_key = CacheKey.HIGH_ELEVATION_LIST
3437
cache_timeout = CacheTimeout.HIGH_ELEVATION_LIST
3538

39+
def get_queryset(self):
40+
now = timezone.now()
41+
cutoff = now - timedelta(hours=24)
42+
43+
return HighElevationForecast.objects.filter(
44+
issued_utc__gte=cutoff
45+
).order_by("-issued_utc")
46+
3647
class HighElevationViewSet(HighElevationAPI, viewsets.ReadOnlyModelViewSet):
3748
pass

0 commit comments

Comments
 (0)