Skip to content

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

@hancush

Description

@hancush

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions