Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do we determine which version of a related matter is "active"? #114

Open
hancush opened this issue Mar 2, 2021 · 0 comments
Open

How do we determine which version of a related matter is "active"? #114

hancush opened this issue Mar 2, 2021 · 0 comments

Comments

@hancush
Copy link
Collaborator

hancush commented Mar 2, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant