Skip to content

Commit

Permalink
Merge pull request #141 from openstates/rj_updates
Browse files Browse the repository at this point in the history
Events to Bills: Add -1 Day to Match Query
  • Loading branch information
NewAgeAirbender authored Sep 16, 2024
2 parents d16a958 + d6c2684 commit 6c7cb58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion openstates/importers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import logging
import typing
from datetime import datetime, timedelta
from django.db.models import Q, Model
from django.db.models.signals import post_save
from .. import settings
Expand Down Expand Up @@ -168,8 +169,12 @@ def resolve_bill(self, bill_id: str, *, date: str) -> typing.Optional[_ID]:
if bill_transform_func:
bill_id = bill_transform_func(bill_id)

# move the start_date up a bit in case the event is on the last day of a session to compare with end_date
date = datetime.fromisoformat(date)
new_date = date - timedelta(days=1)

objects = Bill.objects.filter(
Q(legislative_session__end_date__gte=date)
Q(legislative_session__end_date__gte=new_date)
| Q(legislative_session__end_date=""),
legislative_session__start_date__lte=date,
legislative_session__jurisdiction_id=self.jurisdiction_id,
Expand Down
2 changes: 1 addition & 1 deletion openstates/importers/tests/test_event_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create_other_jurisdiction():
def ge():
event = ScrapeEvent(
name="America's Birthday",
start_date="2014-07-04T05:00Z",
start_date="2014-07-04T05:00:00+00:00",
location_name="America",
all_day=True,
)
Expand Down

0 comments on commit 6c7cb58

Please sign in to comment.