Skip to content

Commit

Permalink
♻️ [#1838] Store zaaktype.url on category instead of identificatie
Browse files Browse the repository at this point in the history
task: https://taiga.maykinmedia.nl/project/open-inwoner/task/1838

to avoid having to resolve a lot of zaaktypes when personalizing the category list
  • Loading branch information
stevenbal committed Nov 14, 2023
1 parent e17fd2c commit dfddb8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/open_inwoner/pdc/admin/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, *args, **kwargs):
f"{zaaktype.catalogus.domein} - {zaaktype.catalogus.rsin}"
].append(
(
zaaktype.identificatie,
zaaktype.url,
zaaktype.omschrijving,
)
)
Expand Down
15 changes: 8 additions & 7 deletions src/open_inwoner/pdc/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ def filter_for_user_with_zaken(self, user: User):

months_since_last_zaak_per_zaaktype = {}
for case in cases:
resolve_zaak_type(case)

duration_since_start = relativedelta(date.today(), case.startdatum)
if (
case.zaaktype.identificatie not in months_since_last_zaak_per_zaaktype
or months_since_last_zaak_per_zaaktype[case.zaaktype.identificatie]
case.zaaktype not in months_since_last_zaak_per_zaaktype
or months_since_last_zaak_per_zaaktype[case.zaaktype]
> duration_since_start.months
):
months_since_last_zaak_per_zaaktype[
case.zaaktype.identificatie
case.zaaktype
] = duration_since_start.months

zaaktype_ids = list(months_since_last_zaak_per_zaaktype.keys())
Expand All @@ -70,9 +68,12 @@ def filter_for_user_with_zaken(self, user: User):
pks.append(category.pk)
continue

for identificatie in category.zaaktypen:
for url in category.zaaktypen:
if url not in months_since_last_zaak_per_zaaktype:
continue

if (
months_since_last_zaak_per_zaaktype[identificatie]
months_since_last_zaak_per_zaaktype[url]
<= category.relevante_zaakperiode
):
pks.append(category.pk)
Expand Down

0 comments on commit dfddb8f

Please sign in to comment.