ds-caselaw-marklogic-api-client 27.4.0__tar.gz → 28.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ds-caselaw-marklogic-api-client might be problematic. Click here for more details.

Files changed (74) hide show
  1. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/PKG-INFO +1 -1
  2. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/pyproject.toml +1 -1
  3. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/Client.py +34 -2
  4. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/factories.py +2 -2
  5. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/__init__.py +28 -7
  6. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/exceptions.py +4 -0
  7. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/judgments.py +7 -6
  8. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/press_summaries.py +7 -6
  9. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/__init__.py +2 -2
  10. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_components_for_document.xqy +1 -1
  11. ds_caselaw_marklogic_api_client-28.0.0/src/caselawclient/xquery/get_recently_enriched.xqy +18 -0
  12. ds_caselaw_marklogic_api_client-28.0.0/src/caselawclient/xquery/get_recently_parsed.xqy +19 -0
  13. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/LICENSE.md +0 -0
  14. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/README.md +0 -0
  15. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/__init__.py +0 -0
  16. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/client_helpers/__init__.py +0 -0
  17. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/client_helpers/search_helpers.py +0 -0
  18. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/content_hash.py +0 -0
  19. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/errors.py +0 -0
  20. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/__init__.py +0 -0
  21. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/body.py +0 -0
  22. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/statuses.py +0 -0
  23. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/transforms/html.xsl +0 -0
  24. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/documents/xml.py +0 -0
  25. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/neutral_citation_mixin.py +0 -0
  26. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/aws.py +0 -0
  27. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/dates.py +0 -0
  28. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/models/utilities/move.py +0 -0
  29. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/py.typed +0 -0
  30. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/__init__.py +0 -0
  31. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/search_response.py +0 -0
  32. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/search_result.py +0 -0
  33. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/responses/xsl/search_match.xsl +0 -0
  34. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/search_parameters.py +0 -0
  35. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xml_helpers.py +0 -0
  36. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/break_judgment_checkout.xqy +0 -0
  37. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/checkin_judgment.xqy +0 -0
  38. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/checkout_judgment.xqy +0 -0
  39. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/copy_document.xqy +0 -0
  40. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/delete_judgment.xqy +0 -0
  41. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/document_collections.xqy +0 -0
  42. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/document_exists.xqy +0 -0
  43. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_combined_stats_table.xqy +0 -0
  44. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_highest_enrichment_version.xqy +0 -0
  45. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_highest_parser_version.xqy +0 -0
  46. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_judgment.xqy +0 -0
  47. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_judgment_checkout_status.xqy +0 -0
  48. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_judgment_version.xqy +0 -0
  49. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_last_modified.xqy +0 -0
  50. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_pending_enrichment_for_version.xqy +0 -0
  51. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_pending_parse_for_version.xqy +0 -0
  52. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_properties_for_search_results.xqy +0 -0
  53. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_property.xqy +0 -0
  54. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_version_annotation.xqy +0 -0
  55. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/get_version_created.xqy +0 -0
  56. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/insert_document.xqy +0 -0
  57. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/list_judgment_versions.xqy +0 -0
  58. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_boolean_property.xqy +0 -0
  59. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_citation.xqy +0 -0
  60. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_court.xqy +0 -0
  61. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_jurisdiction.xqy +0 -0
  62. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_name.xqy +0 -0
  63. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_this_uri.xqy +0 -0
  64. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_metadata_work_expression_date.xqy +0 -0
  65. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/set_property.xqy +0 -0
  66. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/update_document.xqy +0 -0
  67. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/update_locked_judgment.xqy +0 -0
  68. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/user_has_privilege.xqy +0 -0
  69. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/user_has_role.xqy +0 -0
  70. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/validate_all_documents.xqy +0 -0
  71. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/validate_document.xqy +0 -0
  72. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/xslt.xqy +0 -0
  73. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery/xslt_transform.xqy +0 -0
  74. {ds_caselaw_marklogic_api_client-27.4.0 → ds_caselaw_marklogic_api_client-28.0.0}/src/caselawclient/xquery_type_dicts.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ds-caselaw-marklogic-api-client
3
- Version: 27.4.0
3
+ Version: 28.0.0
4
4
  Summary: An API client for interacting with the underlying data in Find Caselaw.
5
5
  Home-page: https://github.com/nationalarchives/ds-caselaw-custom-api-client
6
6
  Keywords: national archives,caselaw
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ds-caselaw-marklogic-api-client"
3
- version = "27.4.0"
3
+ version = "28.0.0"
4
4
  description = "An API client for interacting with the underlying data in Find Caselaw."
5
5
  authors = ["The National Archives"]
6
6
  homepage = "https://github.com/nationalarchives/ds-caselaw-custom-api-client"
@@ -209,12 +209,14 @@ class MarklogicApiClient:
209
209
  Returns a list of PressSummary objects associated with a given Document URI
210
210
  """
211
211
  vars: query_dicts.GetComponentsForDocumentDict = {
212
- "parent_uri": DocumentURIString(uri if uri.startswith("/") else "/" + uri),
212
+ "parent_uri": uri,
213
213
  "component": "pressSummary",
214
214
  }
215
215
  response = self._send_to_eval(vars, "get_components_for_document.xqy")
216
216
  uris = get_multipart_strings_from_marklogic_response(response)
217
- return [PressSummary(uri.strip(".xml"), self) for uri in uris]
217
+ return [
218
+ PressSummary(DocumentURIString(uri.strip("/").strip(".xml")), self) for uri in uris
219
+ ] # TODO: Migrate this strip behaviour into proper manipulation of a MarkLogicURIString
218
220
 
219
221
  def get_document_by_uri(
220
222
  self,
@@ -1107,6 +1109,21 @@ class MarklogicApiClient:
1107
1109
 
1108
1110
  return results
1109
1111
 
1112
+ def get_recently_enriched(
1113
+ self,
1114
+ ) -> list[list[Any]]:
1115
+ """Retrieve documents which are not yet enriched with a given version."""
1116
+ results: list[list[Any]] = json.loads(
1117
+ get_single_string_from_marklogic_response(
1118
+ self._send_to_eval(
1119
+ {},
1120
+ "get_recently_enriched.xqy",
1121
+ ),
1122
+ ),
1123
+ )
1124
+
1125
+ return results
1126
+
1110
1127
  def get_highest_parser_version(self) -> tuple[int, int]:
1111
1128
  """This gets the highest parser version in the database, so if nothing has been parsed with the most recent version of the parser, this won't reflect that change."""
1112
1129
  table = json.loads(
@@ -1141,3 +1158,18 @@ class MarklogicApiClient:
1141
1158
  )
1142
1159
 
1143
1160
  return results
1161
+
1162
+ def get_recently_parsed(
1163
+ self,
1164
+ ) -> list[list[Any]]:
1165
+ """Retrieve documents which are not yet enriched with a given version."""
1166
+ results: list[list[Any]] = json.loads(
1167
+ get_single_string_from_marklogic_response(
1168
+ self._send_to_eval(
1169
+ {},
1170
+ "get_recently_parsed.xqy",
1171
+ ),
1172
+ ),
1173
+ )
1174
+
1175
+ return results
@@ -5,7 +5,7 @@ from unittest.mock import Mock
5
5
  from typing_extensions import TypeAlias
6
6
 
7
7
  from caselawclient.Client import MarklogicApiClient
8
- from caselawclient.models.documents import Document
8
+ from caselawclient.models.documents import Document, DocumentURIString
9
9
  from caselawclient.models.documents.body import DocumentBody
10
10
  from caselawclient.models.judgments import Judgment
11
11
  from caselawclient.models.press_summaries import PressSummary
@@ -54,7 +54,7 @@ class DocumentFactory:
54
54
  @classmethod
55
55
  def build(
56
56
  cls,
57
- uri: str = "test/2023/123",
57
+ uri: DocumentURIString = DocumentURIString("test/2023/123"),
58
58
  html: str = "<p>This is a judgment.</p>",
59
59
  api_client: Optional[MarklogicApiClient] = None,
60
60
  **kwargs: Any,
@@ -1,7 +1,7 @@
1
1
  import datetime
2
2
  import warnings
3
3
  from functools import cached_property
4
- from typing import TYPE_CHECKING, Any, NewType, Optional
4
+ from typing import TYPE_CHECKING, Any, Optional
5
5
 
6
6
  from ds_caselaw_utils import courts
7
7
  from ds_caselaw_utils.courts import CourtNotFoundException
@@ -30,7 +30,7 @@ from caselawclient.models.utilities.aws import (
30
30
  )
31
31
 
32
32
  from .body import DocumentBody
33
- from .exceptions import CannotPublishUnpublishableDocument, DocumentNotSafeForDeletion
33
+ from .exceptions import CannotPublishUnpublishableDocument, DocumentNotSafeForDeletion, InvalidDocumentURIException
34
34
  from .statuses import DOCUMENT_STATUS_HOLD, DOCUMENT_STATUS_IN_PROGRESS, DOCUMENT_STATUS_NEW, DOCUMENT_STATUS_PUBLISHED
35
35
 
36
36
  MINIMUM_ENRICHMENT_TIME = datetime.timedelta(minutes=20)
@@ -47,7 +47,26 @@ if TYPE_CHECKING:
47
47
  from caselawclient.Client import MarklogicApiClient
48
48
 
49
49
 
50
- DocumentURIString = NewType("DocumentURIString", str)
50
+ class DocumentURIString(str):
51
+ """
52
+ This class checks that the string is actually a valid Document URI on creation. It does _not_ manipulate the string.
53
+ """
54
+
55
+ def __new__(cls, content: str) -> "DocumentURIString":
56
+ # Check that the URI doesn't begin or end with a slash
57
+ if content[0] == "/" or content[-1] == "/":
58
+ raise InvalidDocumentURIException(
59
+ f'"{content}" is not a valid document URI; URIs cannot begin or end with slashes.'
60
+ )
61
+
62
+ # Check that the URI doesn't contain a full stop
63
+ if "." in content:
64
+ raise InvalidDocumentURIException(
65
+ f'"{content}" is not a valid document URI; URIs cannot contain full stops.'
66
+ )
67
+
68
+ # If everything is good, return as usual
69
+ return str.__new__(cls, content)
51
70
 
52
71
 
53
72
  class Document:
@@ -105,13 +124,15 @@ class Document:
105
124
  Individual document classes should extend this list where necessary to validate document type-specific attributes.
106
125
  """
107
126
 
108
- def __init__(self, uri: str, api_client: "MarklogicApiClient", search_query: Optional[str] = None):
127
+ def __init__(self, uri: DocumentURIString, api_client: "MarklogicApiClient", search_query: Optional[str] = None):
109
128
  """
110
- :param uri: For historical reasons this accepts a pseudo-URI which may include leading or trailing slashes.
129
+ :param uri: The URI of the document to retrieve from MarkLogic.
130
+ :param api_client: An instance of the API client object to handle communication with the MarkLogic server.
131
+ :param search_query: Optionally, a search string which should be highlighted if it appears in the document body.
111
132
 
112
133
  :raises DocumentNotFoundError: The document does not exist within MarkLogic
113
134
  """
114
- self.uri: DocumentURIString = DocumentURIString(uri.strip("/"))
135
+ self.uri: DocumentURIString = uri
115
136
  self.api_client: MarklogicApiClient = api_client
116
137
  if not self.document_exists():
117
138
  raise DocumentNotFoundError(f"Document {self.uri} does not exist")
@@ -123,7 +144,7 @@ class Document:
123
144
  search_query=search_query,
124
145
  ),
125
146
  )
126
- """ `Document.body` represents the XML of the document itself, without any information such as version tracking or properties. """
147
+ """ `Document.body` represents the body of the document itself, without any information such as version tracking or properties. """
127
148
 
128
149
  def __repr__(self) -> str:
129
150
  name = self.body.name or "un-named"
@@ -4,3 +4,7 @@ class CannotPublishUnpublishableDocument(Exception):
4
4
 
5
5
  class DocumentNotSafeForDeletion(Exception):
6
6
  """A document which is not safe for deletion cannot be deleted."""
7
+
8
+
9
+ class InvalidDocumentURIException(Exception):
10
+ """The document URI is not valid."""
@@ -10,7 +10,7 @@ from caselawclient.models.neutral_citation_mixin import NeutralCitationMixin
10
10
  if TYPE_CHECKING:
11
11
  from caselawclient.models.press_summaries import PressSummary
12
12
 
13
- from .documents import Document
13
+ from .documents import Document, DocumentURIString
14
14
 
15
15
 
16
16
  class Judgment(NeutralCitationMixin, Document):
@@ -21,8 +21,8 @@ class Judgment(NeutralCitationMixin, Document):
21
21
  document_noun = "judgment"
22
22
  document_noun_plural = "judgments"
23
23
 
24
- def __init__(self, *args: Any, **kwargs: Any) -> None:
25
- super().__init__(self.document_noun, *args, **kwargs)
24
+ def __init__(self, uri: DocumentURIString, *args: Any, **kwargs: Any) -> None:
25
+ super().__init__(self.document_noun, uri, *args, **kwargs)
26
26
 
27
27
  @cached_property
28
28
  def neutral_citation(self) -> NeutralCitationString:
@@ -46,8 +46,9 @@ class Judgment(NeutralCitationMixin, Document):
46
46
  Attempt to fetch a linked press summary, and return it, if it exists
47
47
  """
48
48
  try:
49
- uri = self.uri + "/press-summary/1"
50
- PressSummary = importlib.import_module("caselawclient.models.press_summaries").PressSummary
51
- return PressSummary(uri, self.api_client) # type: ignore
49
+ uri = DocumentURIString(self.uri + "/press-summary/1")
50
+ if not TYPE_CHECKING: # This isn't nice, but will be cleaned up when we refactor how related documents work
51
+ PressSummary = importlib.import_module("caselawclient.models.press_summaries").PressSummary
52
+ return PressSummary(uri, self.api_client)
52
53
  except DocumentNotFoundError:
53
54
  return None
@@ -9,7 +9,7 @@ from ds_caselaw_utils.types import NeutralCitationString
9
9
  from caselawclient.errors import DocumentNotFoundError
10
10
  from caselawclient.models.neutral_citation_mixin import NeutralCitationMixin
11
11
 
12
- from .documents import Document
12
+ from .documents import Document, DocumentURIString
13
13
 
14
14
  if TYPE_CHECKING:
15
15
  from caselawclient.models.judgments import Judgment
@@ -23,8 +23,8 @@ class PressSummary(NeutralCitationMixin, Document):
23
23
  document_noun = "press summary"
24
24
  document_noun_plural = "press summaries"
25
25
 
26
- def __init__(self, *args: Any, **kwargs: Any) -> None:
27
- super().__init__(self.document_noun, *args, **kwargs)
26
+ def __init__(self, uri: DocumentURIString, *args: Any, **kwargs: Any) -> None:
27
+ super().__init__(self.document_noun, uri, *args, **kwargs)
28
28
 
29
29
  @cached_property
30
30
  def neutral_citation(self) -> NeutralCitationString:
@@ -47,8 +47,9 @@ class PressSummary(NeutralCitationMixin, Document):
47
47
  Attempt to fetch a linked judgement, and return it, if it exists
48
48
  """
49
49
  try:
50
- uri = self.uri.removesuffix("/press-summary/1")
51
- Judgment = importlib.import_module("caselawclient.models.judgments").Judgment
52
- return Judgment(uri, self.api_client) # type: ignore
50
+ uri = DocumentURIString(self.uri.removesuffix("/press-summary/1"))
51
+ if not TYPE_CHECKING: # This isn't nice, but will be cleaned up when we refactor how related documents work
52
+ Judgment = importlib.import_module("caselawclient.models.judgments").Judgment
53
+ return Judgment(uri, self.api_client)
53
54
  except DocumentNotFoundError:
54
55
  return None
@@ -12,14 +12,14 @@ uk_namespace = {"uk": "https://caselaw.nationalarchives.gov.uk/akn"}
12
12
 
13
13
 
14
14
  class VersionsDict(TypedDict):
15
- uri: str
15
+ uri: str ## TODO: This should be either a MarkLogicDocumentURIString (raw from ML) or a DocumentURIString (and we parse it out). Just a str is too vague.
16
16
  version: int
17
17
 
18
18
 
19
19
  def render_versions(decoded_versions: list[BodyPart]) -> list[VersionsDict]:
20
20
  versions: list[VersionsDict] = [
21
21
  {
22
- "uri": part.text.rstrip(".xml"),
22
+ "uri": part.text.strip("/").rstrip(".xml"),
23
23
  "version": extract_version(part.text),
24
24
  }
25
25
  for part in decoded_versions
@@ -14,7 +14,7 @@ let $docTypeQuery := cts:element-attribute-value-query(
14
14
  )
15
15
  let $refQuery := cts:element-query(
16
16
  xs:QName("uk:summaryOf"),
17
- concat("https://caselaw.nationalarchives.gov.uk/id", $parent_uri)
17
+ concat("https://caselaw.nationalarchives.gov.uk/id/", $parent_uri)
18
18
  )
19
19
 
20
20
  return xdmp:node-uri(cts:search(//akn:akomaNtoso, cts:and-query(($refQuery, $collectionQuery, $docTypeQuery))))
@@ -0,0 +1,18 @@
1
+ xquery version "1.0-ml";
2
+
3
+ declare namespace xdmp="http://marklogic.com/xdmp";
4
+ xdmp:to-json(xdmp:sql(
5
+ "SELECT *, process_data.uri, hours_since_enrichment_request, enrich_major_version, enrich_minor_version
6
+ FROM (
7
+ SELECT
8
+ process_data.uri, enrich_major_version, enrich_minor_version,
9
+ DATEDIFF('hour', last_sent_to_enrichment, CURRENT_TIMESTAMP) AS hours_since_enrichment_request
10
+ FROM documents.process_data
11
+ JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
12
+ )
13
+ ORDER BY hours_since_enrichment_request ASC
14
+ LIMIT 1000",
15
+ "array",
16
+ map:new((
17
+ ))
18
+ ))
@@ -0,0 +1,19 @@
1
+ xquery version "1.0-ml";
2
+
3
+ declare namespace xdmp="http://marklogic.com/xdmp";
4
+ xdmp:to-json(xdmp:sql(
5
+ "SELECT process_data.uri, hours_since_parse_request, parser_major_version, parser_minor_version
6
+ FROM (
7
+ SELECT
8
+ process_data.uri, parser_major_version, parser_minor_version,
9
+ DATEDIFF('hour', last_sent_to_parser, CURRENT_TIMESTAMP) AS hours_since_parse_request
10
+ FROM documents.process_data
11
+ JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
12
+ )
13
+ ORDER BY hours_since_parse_request ASC
14
+ LIMIT 1000",
15
+ "array",
16
+ map:new((
17
+ ))
18
+ ))
19
+