ds-caselaw-marklogic-api-client 27.2.0__py3-none-any.whl → 27.4.0__py3-none-any.whl

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.
caselawclient/Client.py CHANGED
@@ -62,6 +62,8 @@ except importlib.metadata.PackageNotFoundError:
62
62
  VERSION = "0"
63
63
  DEFAULT_USER_AGENT = f"ds-caselaw-marklogic-api-client/{VERSION}"
64
64
 
65
+ DEBUG: bool = bool(os.getenv("DEBUG", default=False))
66
+
65
67
 
66
68
  class NoResponse(Exception):
67
69
  """A requests HTTPError has no response. We expect this will never happen."""
@@ -217,10 +219,10 @@ class MarklogicApiClient:
217
219
  def get_document_by_uri(
218
220
  self,
219
221
  uri: DocumentURIString,
220
- query: Optional[str] = None,
222
+ search_query: Optional[str] = None,
221
223
  ) -> Document:
222
224
  document_type_class = self.get_document_type_from_uri(uri)
223
- return document_type_class(uri, self)
225
+ return document_type_class(uri, self, search_query=search_query)
224
226
 
225
227
  def get_document_type_from_uri(self, uri: DocumentURIString) -> Type[Document]:
226
228
  vars: query_dicts.DocumentCollectionsDict = {
@@ -728,6 +730,10 @@ class MarklogicApiClient:
728
730
  "vars": vars,
729
731
  }
730
732
  path = "LATEST/eval"
733
+
734
+ if DEBUG:
735
+ print(f"Sending {vars} to {xquery_path}")
736
+
731
737
  response = self.session.request(
732
738
  "POST",
733
739
  url=self._path_to_request_url(path),
@@ -1080,6 +1086,7 @@ class MarklogicApiClient:
1080
1086
  self,
1081
1087
  target_enrichment_version: tuple[int, int],
1082
1088
  target_parser_version: tuple[int, int],
1089
+ maximum_records: int = 1000,
1083
1090
  ) -> list[list[Any]]:
1084
1091
  """Retrieve documents which are not yet enriched with a given version."""
1085
1092
  vars: query_dicts.GetPendingEnrichmentForVersionDict = {
@@ -1087,6 +1094,7 @@ class MarklogicApiClient:
1087
1094
  "target_enrichment_minor_version": target_enrichment_version[1],
1088
1095
  "target_parser_major_version": target_parser_version[0],
1089
1096
  "target_parser_minor_version": target_parser_version[1],
1097
+ "maximum_records": maximum_records,
1090
1098
  }
1091
1099
  results: list[list[Any]] = json.loads(
1092
1100
  get_single_string_from_marklogic_response(
@@ -1115,11 +1123,13 @@ class MarklogicApiClient:
1115
1123
  def get_pending_parse_for_version(
1116
1124
  self,
1117
1125
  target_version: tuple[int, int],
1126
+ maximum_records: int = 1000,
1118
1127
  ) -> list[list[Any]]:
1119
1128
  """Retrieve documents which are not yet parsed with a given version."""
1120
1129
  vars: query_dicts.GetPendingParseForVersionDict = {
1121
1130
  "target_major_version": target_version[0],
1122
1131
  "target_minor_version": target_version[1],
1132
+ "maximum_records": maximum_records,
1123
1133
  }
1124
1134
  results: list[list[Any]] = json.loads(
1125
1135
  get_single_string_from_marklogic_response(
@@ -1,35 +1,46 @@
1
1
  xquery version "1.0-ml";
2
2
 
3
+ declare namespace xdmp="http://marklogic.com/xdmp";
3
4
  declare variable $target_enrichment_major_version as xs:int external;
4
5
  declare variable $target_enrichment_minor_version as xs:int external;
5
6
  declare variable $target_parser_major_version as xs:int external;
6
7
  declare variable $target_parser_minor_version as xs:int external;
8
+ declare variable $maximum_records as xs:int? external := 1000;
7
9
 
8
10
  xdmp:to-json(xdmp:sql(
9
11
  "SELECT process_data.uri, enrich_version_string, minutes_since_enrichment_request
10
12
  FROM (
11
13
  SELECT
14
+ propertysummary.published,
12
15
  process_data.uri,
13
16
  enrich_version_string, enrich_major_version, enrich_minor_version,
14
17
  parser_major_version, parser_minor_version,
15
18
  DATEDIFF('minute', last_sent_to_enrichment, CURRENT_TIMESTAMP) AS minutes_since_enrichment_request
16
19
  FROM documents.process_data
17
20
  JOIN documents.process_property_data ON process_data.uri = process_property_data.uri
21
+ JOIN documents.propertysummary ON process_data.uri = propertysummary.uri
18
22
  )
19
- WHERE (
20
- (enrich_version_string IS NULL) OR
21
- (enrich_major_version <= @target_enrichment_major_version AND enrich_minor_version < @target_enrichment_minor_version)
22
- ) AND (
23
- (parser_major_version = @target_parser_major_version AND parser_minor_version = @target_parser_minor_version)
24
- )
25
- AND (minutes_since_enrichment_request > 43200 OR minutes_since_enrichment_request IS NULL)
26
- ORDER BY enrich_major_version ASC NULLS FIRST, enrich_minor_version ASC",
23
+ WHERE
24
+ (minutes_since_enrichment_request > 43200 OR minutes_since_enrichment_request IS NULL) AND
25
+ (propertysummary.published = 'true') AND
26
+ ( enrich_version_string IS NULL
27
+ OR
28
+ (
29
+ (enrich_major_version <= @target_enrichment_major_version AND enrich_minor_version < @target_enrichment_minor_version)
30
+ AND
31
+ (parser_major_version = @target_parser_major_version AND parser_minor_version = @target_parser_minor_version)
32
+ )
33
+ )
34
+ ORDER BY enrich_major_version ASC NULLS FIRST, enrich_minor_version ASC
35
+ LIMIT @maximum_records",
27
36
  "array",
28
37
  map:new((
29
38
  map:entry("target_enrichment_major_version", $target_enrichment_major_version),
30
39
  map:entry("target_enrichment_minor_version", $target_enrichment_minor_version),
31
40
  map:entry("target_parser_major_version", $target_parser_major_version),
32
- map:entry("target_parser_minor_version", $target_parser_minor_version)
41
+ map:entry("target_parser_minor_version", $target_parser_minor_version),
42
+ map:entry("maximum_records", $maximum_records)
43
+
33
44
  ))
34
45
  ))
35
46
 
@@ -2,6 +2,7 @@ xquery version "1.0-ml";
2
2
 
3
3
  declare variable $target_major_version as xs:int external;
4
4
  declare variable $target_minor_version as xs:int external;
5
+ declare variable $maximum_records as xs:int? external := 1000;
5
6
 
6
7
  xdmp:to-json(xdmp:sql(
7
8
  "SELECT process_data.uri, parser_version_string, minutes_since_parse_request
@@ -18,11 +19,13 @@ xdmp:to-json(xdmp:sql(
18
19
  (parser_major_version <= @target_major_version AND parser_minor_version < @target_minor_version)
19
20
  )
20
21
  AND (minutes_since_parse_request > 43200 OR minutes_since_parse_request IS NULL)
21
- ORDER BY parser_major_version ASC NULLS FIRST, parser_minor_version ASC",
22
+ ORDER BY parser_major_version ASC NULLS FIRST, parser_minor_version ASC
23
+ LIMIT @maximum_records",
22
24
  "array",
23
25
  map:new((
24
26
  map:entry("target_major_version", $target_major_version),
25
- map:entry("target_minor_version", $target_minor_version)
27
+ map:entry("target_minor_version", $target_minor_version),
28
+ map:entry("maximum_records", $maximum_records)
29
+
26
30
  ))
27
- ))
28
-
31
+ ))
@@ -88,6 +88,7 @@ class GetLastModifiedDict(MarkLogicAPIDict):
88
88
 
89
89
  # get_pending_enrichment_for_version.xqy
90
90
  class GetPendingEnrichmentForVersionDict(MarkLogicAPIDict):
91
+ maximum_records: Optional[int]
91
92
  target_enrichment_major_version: int
92
93
  target_enrichment_minor_version: int
93
94
  target_parser_major_version: int
@@ -96,6 +97,7 @@ class GetPendingEnrichmentForVersionDict(MarkLogicAPIDict):
96
97
 
97
98
  # get_pending_parse_for_version.xqy
98
99
  class GetPendingParseForVersionDict(MarkLogicAPIDict):
100
+ maximum_records: Optional[int]
99
101
  target_major_version: int
100
102
  target_minor_version: int
101
103
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ds-caselaw-marklogic-api-client
3
- Version: 27.2.0
3
+ Version: 27.4.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,4 +1,4 @@
1
- caselawclient/Client.py,sha256=WKDQaN4b3J3m2pzYdvK4t1MmbeVS9pbtTfqcEH1K-RU,40464
1
+ caselawclient/Client.py,sha256=05vFmk39Gy23i-Mo04pZk_3EmsTe_2feIiwd7fXjDpM,40797
2
2
  caselawclient/__init__.py,sha256=DY-caubLDQWWingSdsBWgovDNXh8KcnkI6kwz08eIFk,612
3
3
  caselawclient/client_helpers/__init__.py,sha256=fyDNKCdrTb2N0Ks23YDhmvlXKfLTHnYQCXhnZb-QQbg,3832
4
4
  caselawclient/client_helpers/search_helpers.py,sha256=R99HyRLeYHgsw2L3DOidEqlKLLvs6Tga5rKTuWQViig,1525
@@ -41,8 +41,8 @@ caselawclient/xquery/get_judgment.xqy,sha256=8V-sEFKmtpf2LIZD9QKVRfpblEsmDpP4BA6
41
41
  caselawclient/xquery/get_judgment_checkout_status.xqy,sha256=mdY9UXLyzQdB7byEERPqentlr0YDLbXRVqH0h4UuZTQ,193
42
42
  caselawclient/xquery/get_judgment_version.xqy,sha256=wF9k9-CBrqo8VbxxyTrD-AGzR3-3jMm25tRVCjxPLrU,292
43
43
  caselawclient/xquery/get_last_modified.xqy,sha256=8fCm_7o_kkytCEmEeSTLWzLP7iOjuPV01IfHDgf6HaQ,172
44
- caselawclient/xquery/get_pending_enrichment_for_version.xqy,sha256=jYc2OPnAIU4kfRsyhCam9RtrxOB2KhKX40CALFc2Rwo,1623
45
- caselawclient/xquery/get_pending_parse_for_version.xqy,sha256=1HRQ3Mwljgp1QbVTiesJrV5HuuMCyKPDMzBOzrT_oQM,1054
44
+ caselawclient/xquery/get_pending_enrichment_for_version.xqy,sha256=8J5Pi-jMXJd_BgtpK4g6C9uR99HP57JpFv5WkoPfNuo,2016
45
+ caselawclient/xquery/get_pending_parse_for_version.xqy,sha256=9cjVZtHeBBjm-a7RMsn1PVJt_Ug78YFlmp5CN8VJ1jQ,1197
46
46
  caselawclient/xquery/get_properties_for_search_results.xqy,sha256=Tlv3EKwVV_q-JyQyhjWVHIleicPDpucxP4ScuQjpgSw,625
47
47
  caselawclient/xquery/get_property.xqy,sha256=RHlOTrK0aH-S7s_ykYzGmUeKOJxXlI4vE5sKRt556NY,209
48
48
  caselawclient/xquery/get_version_annotation.xqy,sha256=pFDMGA9SxI59iUPaoAeUsq23kUp4Op7cUg-PFNFqxcI,262
@@ -65,8 +65,8 @@ caselawclient/xquery/validate_all_documents.xqy,sha256=z_0YEXmRcZ-FaJM0ouKiTjdI4
65
65
  caselawclient/xquery/validate_document.xqy,sha256=PgaDcnqCRJPIVqfmWsNlXmCLNKd21qkJrvY1RtNP7eA,140
66
66
  caselawclient/xquery/xslt.xqy,sha256=w57wNijH3dkwHkpKeAxqjlghVflQwo8cq6jS_sm-erM,199
67
67
  caselawclient/xquery/xslt_transform.xqy,sha256=smyFFxqmtkuOzBd2l7uw6K2oAsYctudrP8omdv_XNAM,2463
68
- caselawclient/xquery_type_dicts.py,sha256=papUzI0k_8l987IpBXwACpnlL4GU1UX1cLt83HpAgds,5622
69
- ds_caselaw_marklogic_api_client-27.2.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
70
- ds_caselaw_marklogic_api_client-27.2.0.dist-info/METADATA,sha256=Aoc0502BWIboWQBs72vD4FHlRAqBZ-V3jVlRn51zO64,4232
71
- ds_caselaw_marklogic_api_client-27.2.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
72
- ds_caselaw_marklogic_api_client-27.2.0.dist-info/RECORD,,
68
+ caselawclient/xquery_type_dicts.py,sha256=AUEmycChASKl8sbqVQWe6WA0s-lIfEqh9mA-GdnUCQ8,5692
69
+ ds_caselaw_marklogic_api_client-27.4.0.dist-info/LICENSE.md,sha256=fGMzyyLuQW-IAXUeDSCrRdsYW536aEWThdbpCjo6ZKg,1108
70
+ ds_caselaw_marklogic_api_client-27.4.0.dist-info/METADATA,sha256=9acabO_PzOjK3LScvlra8WgiyVnNRb7ItdcjIBs1zsg,4232
71
+ ds_caselaw_marklogic_api_client-27.4.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
72
+ ds_caselaw_marklogic_api_client-27.4.0.dist-info/RECORD,,