Skip to content

Commit

Permalink
limit persondata to MP for now
Browse files Browse the repository at this point in the history
This is a hack to resolve the problem of looking up PPC party data for
MPs
  • Loading branch information
struan committed Jul 5, 2024
1 parent 2e92a8f commit f4e9afc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions hub/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def data(self, as_dict=False, mp_name=False):
else:
for row in (
PersonData.objects.filter(
# TODO this is a temporary thing while we come up with a better solution
person__personarea__person_type="MP",
person__personarea__area_id__in=area_ids,
data_type__name=col["name"],
)
Expand Down
12 changes: 10 additions & 2 deletions hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,22 @@ def shader_value(self, area):
return data, min_max["min"], min_max["max"]
else:
min_max = PersonData.objects.filter(
person__areas__in=area, **self.shader_filter
# TODO this is a temporary fix
person__personarea__person_type="MP",
person__areas__in=area,
**self.shader_filter,
).aggregate(
max=models.Max(self.value_col),
min=models.Min(self.value_col),
)

data = (
PersonData.objects.filter(person__areas__in=area, **self.shader_filter)
PersonData.objects.filter(
# TODO this is a temporary fix
person__personarea__person_type="MP",
person__areas__in=area,
**self.shader_filter,
)
.select_related("data_type")
.annotate(gss=models.F("person__areas__gss"))
)
Expand Down

0 comments on commit f4e9afc

Please sign in to comment.