oarepo-runtime 1.5.42__tar.gz → 1.5.43__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. {oarepo_runtime-1.5.42/oarepo_runtime.egg-info → oarepo_runtime-1.5.43}/PKG-INFO +1 -1
  2. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/fixtures.py +1 -8
  3. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/ext.py +3 -3
  4. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/icu.py +3 -8
  5. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/owner.py +1 -8
  6. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/selectors.py +3 -3
  7. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/synthetic.py +2 -1
  8. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/config/service.py +0 -1
  9. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/custom_fields/mappings.py +14 -35
  10. oarepo_runtime-1.5.43/oarepo_runtime/services/facets/__init__.py +32 -0
  11. oarepo_runtime-1.5.43/oarepo_runtime/services/facets/year_histogram.py +200 -0
  12. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/i18n.py +0 -1
  13. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/i18n_ui.py +0 -1
  14. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/search.py +0 -1
  15. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43/oarepo_runtime.egg-info}/PKG-INFO +1 -1
  16. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime.egg-info/SOURCES.txt +1 -0
  17. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/setup.cfg +1 -1
  18. oarepo_runtime-1.5.42/tests/pkg_data/__init__.py +0 -0
  19. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/LICENSE +0 -0
  20. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/MANIFEST.in +0 -0
  21. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/README.md +0 -0
  22. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/__init__.py +0 -0
  23. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/__init__.py +0 -0
  24. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/assets.py +0 -0
  25. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/base.py +0 -0
  26. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/cf.py +0 -0
  27. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/check.py +0 -0
  28. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/configuration.py +0 -0
  29. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/index.py +0 -0
  30. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/cli/validate.py +0 -0
  31. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/__init__.py +0 -0
  32. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/asynchronous.py +0 -0
  33. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/catalogue.py +0 -0
  34. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/datastreams.py +0 -0
  35. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/errors.py +0 -0
  36. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/ext.py +0 -0
  37. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/fixtures.py +0 -0
  38. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/json.py +0 -0
  39. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
  40. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/readers/attachments.py +0 -0
  41. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/readers/excel.py +0 -0
  42. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/readers/json.py +0 -0
  43. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/readers/service.py +0 -0
  44. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
  45. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/semi_asynchronous.py +0 -0
  46. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/synchronous.py +0 -0
  47. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/transformers.py +0 -0
  48. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/types.py +0 -0
  49. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/utils.py +0 -0
  50. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
  51. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/writers/attachments_file.py +0 -0
  52. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/writers/attachments_service.py +0 -0
  53. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/writers/service.py +0 -0
  54. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/writers/utils.py +0 -0
  55. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/writers/validation_errors.py +0 -0
  56. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
  57. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/ext_config.py +0 -0
  58. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/i18n/__init__.py +0 -0
  59. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/info/__init__.py +0 -0
  60. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/info/views.py +0 -0
  61. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/profile.py +0 -0
  62. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/proxies.py +0 -0
  63. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/__init__.py +0 -0
  64. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/dumpers/__init__.py +0 -0
  65. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/dumpers/edtf_interval.py +0 -0
  66. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/dumpers/multilingual_dumper.py +0 -0
  67. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/entity_resolvers/__init__.py +0 -0
  68. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/entity_resolvers/proxies.py +0 -0
  69. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/owners/__init__.py +0 -0
  70. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/owners/registry.py +0 -0
  71. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/relations/__init__.py +0 -0
  72. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/relations/base.py +0 -0
  73. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/relations/internal.py +0 -0
  74. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/relations/lookup.py +0 -0
  75. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/relations/pid_relation.py +0 -0
  76. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/__init__.py +0 -0
  77. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/featured_file.py +0 -0
  78. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/has_draftcheck.py +0 -0
  79. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/mapping.py +0 -0
  80. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/records/systemfields/record_status.py +0 -0
  81. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/resources/__init__.py +0 -0
  82. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/resources/file_resource.py +0 -0
  83. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/resources/localized_ui_json_serializer.py +0 -0
  84. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/__init__.py +0 -0
  85. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/components.py +0 -0
  86. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/config/__init__.py +0 -0
  87. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/config/permissions_presets.py +0 -0
  88. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/custom_fields/__init__.py +0 -0
  89. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/expansions/__init__.py +0 -0
  90. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/expansions/expandable_fields.py +0 -0
  91. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/expansions/service.py +0 -0
  92. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/facets/base.py +0 -0
  93. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/facets/date.py +0 -0
  94. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/facets/enum.py +0 -0
  95. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/facets/facet_groups_names.py +0 -0
  96. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/facets/max_facet.py +0 -0
  97. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/facets/nested_facet.py +0 -0
  98. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/facets/params.py +0 -0
  99. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/files/__init__.py +0 -0
  100. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/files/components.py +0 -0
  101. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/files/service.py +0 -0
  102. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/generators.py +0 -0
  103. {oarepo_runtime-1.5.42/oarepo_runtime/services/facets → oarepo_runtime-1.5.43/oarepo_runtime/services/relations}/__init__.py +0 -0
  104. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/relations/components.py +0 -0
  105. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/relations/errors.py +0 -0
  106. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/relations/mapping.py +0 -0
  107. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/results.py +0 -0
  108. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/__init__.py +0 -0
  109. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/cf.py +0 -0
  110. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/i18n_validation.py +0 -0
  111. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/marshmallow.py +0 -0
  112. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/oneofschema.py +0 -0
  113. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/polymorphic.py +0 -0
  114. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/ui.py +0 -0
  115. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/services/schema/validation.py +0 -0
  116. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
  117. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -0
  118. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/translations/default_translations.py +0 -0
  119. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/translations/en/LC_MESSAGES/messages.mo +0 -0
  120. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -0
  121. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/translations/jinjax_messages.jinja +0 -0
  122. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/translations/messages.pot +0 -0
  123. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/uow.py +0 -0
  124. {oarepo_runtime-1.5.42/oarepo_runtime/services/relations → oarepo_runtime-1.5.43/oarepo_runtime/utils}/__init__.py +0 -0
  125. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/utils/functools.py +0 -0
  126. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime/utils/path.py +0 -0
  127. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
  128. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime.egg-info/entry_points.txt +0 -0
  129. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime.egg-info/requires.txt +0 -0
  130. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/oarepo_runtime.egg-info/top_level.txt +0 -0
  131. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/pyproject.toml +0 -0
  132. {oarepo_runtime-1.5.42 → oarepo_runtime-1.5.43}/setup.py +0 -0
  133. {oarepo_runtime-1.5.42/oarepo_runtime/utils → oarepo_runtime-1.5.43/tests/pkg_data}/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.42
3
+ Version: 1.5.43
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -2,14 +2,7 @@ import click
2
2
  import tqdm
3
3
  from flask import current_app
4
4
  from flask.cli import with_appcontext
5
- from flask_login import login_user
6
- from flask_principal import (
7
- Identity,
8
- RoleNeed,
9
- UserNeed,
10
- identity_changed,
11
- identity_loaded,
12
- )
5
+ from flask_principal import Identity, RoleNeed, UserNeed
13
6
  from invenio_access.permissions import any_user, authenticated_user, system_identity
14
7
  from invenio_accounts.models import User
15
8
 
@@ -39,9 +39,9 @@ class OARepoRuntime(object):
39
39
 
40
40
  for k in ext_config.OAREPO_PERMISSIONS_PRESETS:
41
41
  if k not in app.config["OAREPO_PERMISSIONS_PRESETS"]:
42
- app.config["OAREPO_PERMISSIONS_PRESETS"][
43
- k
44
- ] = ext_config.OAREPO_PERMISSIONS_PRESETS[k]
42
+ app.config["OAREPO_PERMISSIONS_PRESETS"][k] = (
43
+ ext_config.OAREPO_PERMISSIONS_PRESETS[k]
44
+ )
45
45
 
46
46
  for k in dir(ext_config):
47
47
  if k == "DEFAULT_DATASTREAMS_EXCLUDES":
@@ -148,9 +148,7 @@ class ICUSearchField(ICUField):
148
148
  },
149
149
  "ascii_folding_analyzer": {
150
150
  "tokenizer": "standard",
151
- "filter": [
152
- "ascii_folding_filter"
153
- ]
151
+ "filter": ["ascii_folding_filter"],
154
152
  },
155
153
  }
156
154
 
@@ -165,10 +163,7 @@ class ICUSearchField(ICUField):
165
163
  "name": "english",
166
164
  "language": "english",
167
165
  },
168
- "ascii_folding_filter": {
169
- "type": "asciifolding",
170
- "preserve_original": True
171
- }
166
+ "ascii_folding_filter": {"type": "asciifolding", "preserve_original": True},
172
167
  }
173
168
 
174
169
  def __init__(self, source_field, key=None):
@@ -197,7 +192,7 @@ class ICUSearchField(ICUField):
197
192
  "analyzer": "ascii_folding_analyzer",
198
193
  "boost": 0.3,
199
194
  },
200
- }
195
+ },
201
196
  },
202
197
  )
203
198
  for lang, setting in self.languages.items()
@@ -7,8 +7,6 @@
7
7
  # details.
8
8
 
9
9
  """Communities system field."""
10
- import functools
11
- import inspect
12
10
 
13
11
  from invenio_records.systemfields import SystemField
14
12
 
@@ -82,12 +80,7 @@ class OwnersField(MappingSystemFieldMixin, SystemField):
82
80
  return {
83
81
  self.attr_name: {
84
82
  "type": "object",
85
- "properties": {
86
- "user": {
87
- "type": "keyword",
88
- "ignore_above": 256
89
- }
90
- }
83
+ "properties": {"user": {"type": "keyword", "ignore_above": 256}},
91
84
  },
92
85
  }
93
86
 
@@ -1,12 +1,12 @@
1
- from typing import List
1
+ from typing import List, Any
2
2
 
3
3
 
4
4
  class Selector:
5
- def select(self, record):
5
+ def select(self, record) -> List[Any]:
6
6
  return []
7
7
 
8
8
 
9
- class PathSelector:
9
+ class PathSelector(Selector):
10
10
  def __init__(self, *paths):
11
11
  self.paths = [x.split(".") for x in paths]
12
12
 
@@ -2,6 +2,7 @@ import logging
2
2
 
3
3
  from invenio_records.systemfields import SystemField
4
4
 
5
+ from . import Selector
5
6
  from .mapping import MappingSystemFieldMixin
6
7
 
7
8
  log = logging.getLogger(__name__)
@@ -69,7 +70,7 @@ class SyntheticSystemField(MappingSystemFieldMixin, SystemField):
69
70
  ```
70
71
  """
71
72
 
72
- def __init__(self, selector=None, filter=None, map=None, key=None, **kwargs):
73
+ def __init__(self, selector: Selector=None, filter=None, map=None, key=None, **kwargs):
73
74
  self.selector = selector
74
75
  self.map = map
75
76
  self.filter = filter
@@ -4,7 +4,6 @@ from typing import List, Type
4
4
 
5
5
  from flask import current_app
6
6
  from flask_principal import RoleNeed
7
- from invenio_accounts.models import User
8
7
  from invenio_records_permissions import BasePermissionPolicy
9
8
  from invenio_records_permissions.generators import Generator
10
9
  from invenio_search.engine import dsl
@@ -19,7 +19,7 @@ from oarepo_runtime.records.systemfields.mapping import MappingSystemFieldMixin
19
19
  class Mapping(InvenioMapping):
20
20
  @classmethod
21
21
  def properties_for_fields(
22
- cls, given_fields_names, available_fields, field_name="custom_fields"
22
+ cls, given_fields_names, available_fields, field_name="custom_fields"
23
23
  ):
24
24
  """Prepare search mapping properties for each field."""
25
25
 
@@ -34,7 +34,7 @@ class Mapping(InvenioMapping):
34
34
 
35
35
  @classmethod
36
36
  def settings_for_fields(
37
- cls, given_fields_names, available_fields, field_name="custom_fields"
37
+ cls, given_fields_names, available_fields, field_name="custom_fields"
38
38
  ):
39
39
  """Prepare mapping settings for each field."""
40
40
 
@@ -87,9 +87,7 @@ def prepare_cf_index(record_class, config, path=[]):
87
87
  dynamic_templates = fld.dynamic_templates
88
88
 
89
89
  for pth in reversed(path):
90
- mapping = {
91
- pth: mapping
92
- }
90
+ mapping = {pth: mapping}
93
91
 
94
92
  # upload mapping
95
93
  try:
@@ -124,43 +122,24 @@ def prepare_parent_mapping(parent_class, config):
124
122
  "properties": {
125
123
  "created": {
126
124
  "type": "date",
127
- "format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction"
128
- },
129
- "id": {
130
- "type": "keyword",
131
- "ignore_above": 1024
125
+ "format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
132
126
  },
127
+ "id": {"type": "keyword", "ignore_above": 1024},
133
128
  "pid": {
134
129
  "properties": {
135
- "obj_type": {
136
- "type": "keyword",
137
- "ignore_above": 1024
138
- },
139
- "pid_type": {
140
- "type": "keyword",
141
- "ignore_above": 1024
142
- },
143
- "pk": {
144
- "type": "long"
145
- },
146
- "status": {
147
- "type": "keyword",
148
- "ignore_above": 1024
149
- }
130
+ "obj_type": {"type": "keyword", "ignore_above": 1024},
131
+ "pid_type": {"type": "keyword", "ignore_above": 1024},
132
+ "pk": {"type": "long"},
133
+ "status": {"type": "keyword", "ignore_above": 1024},
150
134
  }
151
135
  },
152
136
  "updated": {
153
137
  "type": "date",
154
- "format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction"
155
- },
156
- "uuid": {
157
- "type": "keyword",
158
- "ignore_above": 1024
138
+ "format": "strict_date_time||strict_date_time_no_millis||basic_date_time||basic_date_time_no_millis||basic_date||strict_date||strict_date_hour_minute_second||strict_date_hour_minute_second_fraction",
159
139
  },
160
- "version_id": {
161
- "type": "long"
162
- }
163
- }
140
+ "uuid": {"type": "keyword", "ignore_above": 1024},
141
+ "version_id": {"type": "long"},
142
+ },
164
143
  }
165
144
  }
166
145
 
@@ -204,6 +183,6 @@ def update_index(record_index, settings, mapping, dynamic_templates=None):
204
183
 
205
184
  def get_mapping_fields(record_class) -> Iterable[MappingSystemFieldMixin]:
206
185
  for cfg_name, cfg_value in inspect.getmembers(
207
- record_class, lambda x: isinstance(x, MappingSystemFieldMixin)
186
+ record_class, lambda x: isinstance(x, MappingSystemFieldMixin)
208
187
  ):
209
188
  yield cfg_value
@@ -0,0 +1,32 @@
1
+ from .base import LabelledValuesTermsFacet
2
+ from .date import (
3
+ AutoDateHistogramFacet,
4
+ DateFacet,
5
+ DateIntervalFacet,
6
+ DateTimeFacet,
7
+ EDTFIntervalFacet,
8
+ TimeFacet,
9
+ )
10
+ from .enum import EnumTermsFacet
11
+ from .facet_groups_names import facet_groups_names
12
+ from .max_facet import MaxFacet
13
+ from .nested_facet import NestedLabeledFacet
14
+ from .params import FilteredFacetsParam, GroupedFacetsParam
15
+ from .year_histogram import YearAutoHistogramFacet
16
+
17
+ __all__ = [
18
+ "LabelledValuesTermsFacet",
19
+ "DateFacet",
20
+ "TimeFacet",
21
+ "DateTimeFacet",
22
+ "AutoDateHistogramFacet",
23
+ "EDTFIntervalFacet",
24
+ "DateIntervalFacet",
25
+ "EnumTermsFacet",
26
+ "facet_groups_names",
27
+ "MaxFacet",
28
+ "NestedLabeledFacet",
29
+ "GroupedFacetsParam",
30
+ "FilteredFacetsParam",
31
+ "YearAutoHistogramFacet",
32
+ ]
@@ -0,0 +1,200 @@
1
+ import re
2
+ from typing import Dict, List
3
+
4
+ from invenio_records_resources.services.records.facets.facets import LabelledFacetMixin
5
+ from invenio_search.engine import dsl
6
+
7
+
8
+ class YearAutoHistogramFacet(LabelledFacetMixin, dsl.Facet):
9
+ """Histogram facet.
10
+
11
+ .. code-block:: python
12
+
13
+ facets = {
14
+ 'year': IntegerHistogramFacet(
15
+ field='year',
16
+ label=_('Year'),
17
+ size=1000000
18
+ )
19
+ }
20
+
21
+ Usage in the oarepo model together with SyntheticSystemField::
22
+ record:
23
+ record:
24
+ imports:
25
+ - import: oarepo_runtime.records.systemfields.SyntheticSystemField
26
+ - import: oarepo_runtime.records.systemfields.PathSelector
27
+ fields:
28
+ year: |
29
+ SyntheticSystemField(
30
+ selector=PathSelector("metadata.date"),
31
+ key="year",
32
+ filter=lambda x: len(x) >= 4,
33
+ map=lambda x: x[:4]
34
+ )
35
+ properties:
36
+ year:
37
+ facets:
38
+ facet-class: oarepo_runtime.services.facets.year_histogram.YearAutoHistogramFacet
39
+ type: edtf
40
+ """
41
+
42
+ agg_type = "auto_date_histogram"
43
+
44
+ def __init__(self, **kwargs):
45
+ self._min_doc_count = kwargs.pop("min_doc_count", 0)
46
+ buckets = kwargs.pop("buckets", 20)
47
+ # TODO: the minimum interval should be year, but opensearch does not support it yet
48
+ super().__init__(
49
+ **kwargs, buckets=buckets, format="yyyy", minimum_interval="month"
50
+ )
51
+
52
+ def get_value_filter(self, filter_value):
53
+ if "/" in filter_value:
54
+ start, end = filter_value.split("/")
55
+ return dsl.query.Range(
56
+ _expand__to_dot=False,
57
+ **{
58
+ self._params["field"]: {
59
+ "gte": f"{start}-01-01",
60
+ "lte": f"{end}-12-31",
61
+ }
62
+ },
63
+ )
64
+ return dsl.query.Term(
65
+ _expand__to_dot=False,
66
+ **{
67
+ self._params["field"]: {
68
+ "gte": f"{filter_value}-01-01",
69
+ "lte": f"{filter_value}-12-31",
70
+ }
71
+ },
72
+ )
73
+
74
+ def add_filter(self, filter_values):
75
+ ret = super().add_filter(filter_values)
76
+ return ret
77
+
78
+ def get_labelled_values(self, data, filter_values):
79
+ """Get a labelled version of a bucket."""
80
+
81
+ # fix for opensearch bug
82
+ data = self.fix_yearly_interval(data)
83
+
84
+ interval = data["interval"]
85
+
86
+ interval_in_years = int(re.sub(r"\D", "", interval))
87
+
88
+ buckets = data["buckets"]
89
+
90
+ for bucket in buckets:
91
+ bucket["interval"] = interval_in_years
92
+
93
+ if self._min_doc_count > 0:
94
+ buckets = self._merge_small_buckets(buckets)
95
+
96
+ out_buckets = []
97
+ for i, bucket in enumerate(buckets):
98
+ value = int(bucket["key_as_string"].split("-")[0])
99
+
100
+ out_buckets.append(
101
+ {
102
+ **bucket,
103
+ "interval": f"{bucket['interval']}y",
104
+ "start": str(value),
105
+ }
106
+ )
107
+ if i > 0:
108
+ out_buckets[i - 1]["end"] = str(value - 1)
109
+
110
+ if out_buckets:
111
+ out_buckets[-1]["end"] = str(
112
+ int(out_buckets[-1]["start"]) + interval_in_years - 1
113
+ )
114
+
115
+ return {
116
+ "buckets": out_buckets,
117
+ "label": str(self._label),
118
+ "interval": interval,
119
+ }
120
+
121
+ def merge_buckets(self, buckets):
122
+ merged = {}
123
+
124
+ for bucket in buckets:
125
+ key = bucket["key_as_string"]
126
+ if key not in merged:
127
+ merged[key] = {
128
+ "key_as_string": key,
129
+ "key": bucket["key"],
130
+ "doc_count": 0,
131
+ }
132
+
133
+ merged[key]["doc_count"] += bucket["doc_count"]
134
+
135
+ result = list(merged.values())
136
+ return result
137
+
138
+ def fix_yearly_interval(self, data) -> Dict:
139
+ """
140
+ Currently opensearch has a bug that does not allow to set minimum_interval to year.
141
+ This function will fix the interval to be yearly if the minimum_interval is has lower value.
142
+ """
143
+ data = data.to_dict()
144
+
145
+ interval = data["interval"]
146
+
147
+ if interval.endswith("y"):
148
+ # no need to fix the interval, as it is in years
149
+ return data
150
+
151
+ # make sure it is in years
152
+ data["interval"] = "1y"
153
+
154
+ buckets = data["buckets"]
155
+ data["buckets"] = out_buckets = []
156
+
157
+ by_year = {}
158
+
159
+ # there might be several buckets returned with the same year - merge them
160
+ for bucket in buckets:
161
+ key = bucket["key_as_string"]
162
+ if key not in by_year:
163
+ by_year[key] = {
164
+ "key_as_string": key,
165
+ "key": bucket["key"],
166
+ "doc_count": 0,
167
+ }
168
+ out_buckets.append(by_year[key])
169
+
170
+ by_year[key]["doc_count"] += bucket["doc_count"]
171
+
172
+ return data
173
+
174
+ def _merge_small_buckets(self, buckets: List[Dict]):
175
+ """
176
+ Merges small buckets into the previous bucket. If the small bucket is the first one,
177
+ merge it with subsequent buckets until the first non-small bucket is found.
178
+ """
179
+ ret = []
180
+ initial_small_buckets = 0
181
+ initial_small_interval = 0
182
+ for bucket in buckets:
183
+ if bucket["doc_count"] < self._min_doc_count:
184
+ if ret:
185
+ ret[-1]["doc_count"] += bucket["doc_count"]
186
+ ret[-1]["interval"] += bucket["interval"]
187
+ else:
188
+ initial_small_buckets += bucket["doc_count"]
189
+ initial_small_interval += bucket["interval"]
190
+ else:
191
+ ret.append(bucket)
192
+
193
+ if ret and initial_small_buckets:
194
+ doc_count = ret[0]["doc_count"] + initial_small_buckets
195
+ interval = ret[0]["interval"] + initial_small_interval
196
+ ret[0] = buckets[0]
197
+ ret[0]["doc_count"] = doc_count
198
+ ret[0]["interval"] = interval
199
+
200
+ return ret
@@ -1,4 +1,3 @@
1
- import importlib
2
1
  from functools import lru_cache
3
2
 
4
3
  import langcodes
@@ -2,7 +2,6 @@ from functools import lru_cache
2
2
 
3
3
  from invenio_base.utils import obj_or_import_string
4
4
  from marshmallow import Schema, fields
5
- from marshmallow_utils.fields import SanitizedHTML
6
5
 
7
6
 
8
7
  @lru_cache
@@ -14,7 +14,6 @@ from invenio_records_resources.services.records.params import (
14
14
  from invenio_records_resources.services.records.queryparser import SuggestQueryParser
15
15
  from invenio_search.engine import dsl
16
16
 
17
-
18
17
  # TODO: integrate this to invenio_records_resources.services.records and remove SearchOptions class
19
18
  from oarepo_runtime.i18n import lazy_gettext as _
20
19
  from oarepo_runtime.records.systemfields.icu import ICUSuggestField
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.42
3
+ Version: 1.5.43
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -100,6 +100,7 @@ oarepo_runtime/services/facets/facet_groups_names.py
100
100
  oarepo_runtime/services/facets/max_facet.py
101
101
  oarepo_runtime/services/facets/nested_facet.py
102
102
  oarepo_runtime/services/facets/params.py
103
+ oarepo_runtime/services/facets/year_histogram.py
103
104
  oarepo_runtime/services/files/__init__.py
104
105
  oarepo_runtime/services/files/components.py
105
106
  oarepo_runtime/services/files/service.py
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = oarepo-runtime
3
- version = 1.5.42
3
+ version = 1.5.43
4
4
  description = A set of runtime extensions of Invenio repository
5
5
  authors = Alzbeta Pokorna
6
6
  readme = README.md
File without changes
File without changes