This PR reorganizes the refresh_pic management command and adds a method to retrieve bill versions, as well as bill documents, for cache refresh. This handles a bug where updating the bill itself did not trigger a cache refresh, since that resource is stored as a BillVersion, not a BillDocument. More: https://github.com/datamade/la-metro-councilmatic/issues/621
Testing instructions
The tests have been updated to cover this case.
I also shelled into the production server and confirm that this logic would have captured the bill that was not updated:
>>> import datetime
>>> from django.conf import settings
>>> from opencivicdata.legislative.models import *
>>> from pytz import timezone
>>> from lametro.models import LAMetroBill
>>> app_timezone = pytz.timezone(settings.TIME_ZONE)
>>> june_17 = app_timezone.localize(datetime.datetime(2020, 6, 17))
>>> bills_on_upcoming_agendas = EventRelatedEntity.objects.filter(bill__isnull=False, agenda_item__event__start_date__gt=june_17).filter(bill__identifier='2020-0414')
>>> bills_on_upcoming_agendas
<QuerySet [<EventRelatedEntity: 2020-0414 related to Agenda item 21 for Executive Management Committee (2020-06-18T18:30:00+00:00)>, <EventRelatedEntity: 2020-0414 related to Agenda item 40 for Regular Board Meeting (2020-06-25T17:00:00+00:00)>]>
>>> upcoming = bills_on_upcoming_agendas.values_list('bill_id')
>>> BillVersionLink.objects.filter(version__bill__id__in=upcoming)
<QuerySet [<BillVersionLink: https://metro.legistar.com/ViewReport.ashx?M=R&N=TextL5&GID=557&ID=6856&GUID=LATEST&Title=Board+Report for version of 2020-0414 in Los Angeles County Metropolitan Transportation Authority >]>
Description
This PR reorganizes the
refresh_pic
management command and adds a method to retrieve bill versions, as well as bill documents, for cache refresh. This handles a bug where updating the bill itself did not trigger a cache refresh, since that resource is stored as aBillVersion
, not aBillDocument
. More: https://github.com/datamade/la-metro-councilmatic/issues/621Testing instructions