Skip to content

Commit a4fafd1

Browse files
author
Dmytro Trotsko
committed
Include ILINET indicator set into table when doing location filtering
1 parent 0e90bc6 commit a4fafd1

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/alternative_interface/helper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
"state:WI": "WI",
6262
"state:WV": "WV",
6363
"state:WY": "WY",
64+
# fluview (ILINET) specific locations
65+
"ny_minus_jfk:ny_minus_jfk": "NY (minus NYC)",
66+
"us-territory:as": "American Samoa",
67+
"us-territory:mp": "Mariana Islands",
68+
"us-territory:gu": "Guam",
69+
"us-territory:pr": "Puerto Rico",
70+
"us-territory:vi": "Virgin Islands",
71+
"us-city:ord": "Chicago",
72+
"us-city:lax": "Los Angeles",
73+
"us-city:jfk": "New York City",
6474
}
6575

6676
EXPRESS_VIEW_LABELS_MAPPING = {

src/indicatorsets/filters.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import ast
23

34

45
import django_filters
@@ -13,6 +14,7 @@
1314
)
1415
from indicators.models import Indicator
1516
from base.models import Pathogen, Geography, SeverityPyramidRung
17+
from alternative_interface.helper import COVIDCAST_FLUVIEW_LOCATIONS_MAPPING
1618

1719

1820
logger = logging.getLogger(__name__)
@@ -123,18 +125,27 @@ def hosted_by_delphi_filter(self, queryset, name, value):
123125

124126
return queryset
125127

128+
@staticmethod
129+
def include_fluview(values):
130+
include_fluview = False
131+
for value in ast.literal_eval(values):
132+
if COVIDCAST_FLUVIEW_LOCATIONS_MAPPING.get(value):
133+
include_fluview = True
134+
break
135+
return include_fluview
136+
126137
def location_search_filter(self, queryset, name, value):
127138
if not value:
128139
return queryset
140+
indicator_sets = []
129141
filtered_indicators = get_list_of_indicators_filtered_by_geo(value)
142+
include_fluview = self.include_fluview(value)
143+
query = Q()
130144
if filtered_indicators["epidata"]:
131-
query = Q()
132145
for item in filtered_indicators["epidata"]:
133146
query |= Q(source__name=item["source"], name=item["signal"])
134-
self.indicators_qs = self.indicators_qs.filter(query)
135-
indicator_sets = self.indicators_qs.values_list(
136-
"indicator_set_id", flat=True
137-
).distinct()
138-
return queryset.filter(id__in=indicator_sets)
139-
else:
140-
return IndicatorSet.objects.none()
147+
if include_fluview:
148+
query |= Q(indicator_set__epidata_endpoint="fluview")
149+
self.indicators_qs = self.indicators_qs.filter(query)
150+
indicator_sets = list(self.indicators_qs.values_list("indicator_set_id", flat=True).order_by("indicator_set_id").distinct())
151+
return queryset.filter(id__in=indicator_sets)

0 commit comments

Comments
 (0)