We introduced logic in #112 to retrieve the most recent version of every matter relation. This relies on the assumption that the most recent version is the active version, but per Metro-Records/la-metro-councilmatic#669 (comment), this is not always the case. Omar thought Regina might have implemented some logic to determine which version is active, but I can't find it.
The revised implementation exposes a method to apply a different filter to matter relations, so maybe this is a question we allow users of this library to answer themselves:
|
def _filter_relations(self, relations): |
|
''' |
|
Sometimes, many versions of a bill are related. This method returns the |
|
most recent version of each relation. Override this method to apply a |
|
different filter or return the full array of relations. |
|
''' |
|
# Sort relations such that the latest version of each matter |
|
# ID is returned first. |
|
sorted_relations = sorted( |
|
relations, |
|
key=lambda x: ( |
|
x['MatterRelationMatterId'], |
|
x['MatterRelationFlag'] |
|
), |
|
reverse=True |
|
) |
|
|
|
seen_relations = set() |
|
|
|
for relation in sorted_relations: |
|
relation_id = relation['MatterRelationMatterId'] |
|
|
|
if relation_id not in seen_relations: |
|
yield relation |
|
seen_relations.add(relation_id) |
We introduced logic in #112 to retrieve the most recent version of every matter relation. This relies on the assumption that the most recent version is the active version, but per Metro-Records/la-metro-councilmatic#669 (comment), this is not always the case. Omar thought Regina might have implemented some logic to determine which version is active, but I can't find it.
The revised implementation exposes a method to apply a different filter to matter relations, so maybe this is a question we allow users of this library to answer themselves:
python-legistar-scraper/legistar/bills.py
Lines 424 to 448 in 83cb634