Skip to content

Commit

Permalink
Merge branch 'develop' into CU-868656ku9
Browse files Browse the repository at this point in the history
  • Loading branch information
Afani97 authored Nov 15, 2023
2 parents 0bd8b4a + 89c910e commit fe85757
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def create_searches_df(self, qs, year=None):
.order_by("year")
)
if qs.count() == 0:
return None
return pd.DataFrame()
df = pd.DataFrame(qs)
pivot_df = df.pivot(
index="year", columns=["stop_purpose_group", "driver_race_comb"], values="count"
Expand Down Expand Up @@ -888,7 +888,7 @@ def get_qs(self, _filter, year=None):

def create_contraband_df(self, qs, contraband_found):
if not contraband_found:
return None
return pd.DataFrame()
qs = (
qs.values("year", "driver_race_comb", "stop_purpose_group", contraband_found)
.annotate(count=Count(contraband_found))
Expand All @@ -908,7 +908,7 @@ def create_dataset(self, contraband_qs, stop_purpose, *args, **kwargs):
}
for c in self.columns:
searches_df = self.create_searches_df(searches_qs, year)
if not searches_df or searches_df.empty:
if searches_df.empty:
continue
contraband_df = self.create_contraband_df(contraband_qs, contraband)

Expand Down Expand Up @@ -978,7 +978,7 @@ def get(self, request, agency_id):
contraband_qs = self.get_qs(Q(stop__agency__id=agency_id, person__type="D"), year)

contraband_df = self.create_contraband_df(contraband_qs, contraband_type)
if not contraband_df or contraband_df.empty:
if contraband_df.empty:
return Response(data={}, status=200)
contraband_df = contraband_df[contraband_df["stop_purpose_group"] == grouped_stop_purpose]
contraband_df = contraband_df[contraband_df[contraband_type] == True] # noqa E712
Expand Down

0 comments on commit fe85757

Please sign in to comment.