Skip to content

Commit

Permalink
Return published to previous functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Feb 3, 2025
1 parent 715ba25 commit 32b9174
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/caselawclient/identifier_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ class IdentifierResolutions(list["IdentifierResolution"]):
def from_marklogic_output(table: list[str]) -> "IdentifierResolutions":
return IdentifierResolutions(list(IdentifierResolution.from_marklogic_output(row) for row in table))

def published(self, only_published: bool = True) -> "IdentifierResolutions":
def published(self) -> "IdentifierResolutions":
"Filter the list so that only published documents are returned"
if not only_published:
return self
return IdentifierResolutions(list(x for x in self if x.document_published))


Expand Down
10 changes: 6 additions & 4 deletions src/caselawclient/models/documents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,16 @@ def linked_document_resolutions(self, namespaces: list[str], only_published: boo
"""Get documents which share the same neutral citation as this document."""
if not hasattr(self, "neutral_citation") or not self.neutral_citation:
return IdentifierResolutions([])
all_similar_resolutions = self.api_client.resolve_from_identifier_value(self.neutral_citation).published(
only_published=only_published
)

resolutions = self.api_client.resolve_from_identifier_value(self.neutral_citation)
if only_published:
resolutions = resolutions.published()

# only documents which aren't this one and have a right namespace
return IdentifierResolutions(
[
resolution
for resolution in all_similar_resolutions
for resolution in resolutions
if resolution.document_uri != self.uri.as_marklogic() and resolution.identifier_namespace in namespaces
]
)

0 comments on commit 32b9174

Please sign in to comment.