Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4396,3 +4396,5 @@ def search_type(field):
RERO_FILES_RECORD_FILE_SERVICE_CONFIG = (
"rero_ils.modules.files.services.RecordFileServiceConfig"
)
RERO_ILS_APP_FILES_UI_MAX = 600
RERO_ILS_APP_FILES_FULL_TEXT_MAX = 10 * 1024 * 1024 # 10Mb
1 change: 1 addition & 0 deletions rero_ils/es_templates/v7/record.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"circ_policies-*",
"collections-*",
"documents-*",
"files-*",
"holdings-*",
"ill_requests-*",
"item_types-*",
Expand Down
15 changes: 10 additions & 5 deletions rero_ils/modules/documents/dumpers/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ def _process_provision_activity(record, data):

def _process_files(self, record, data):
"""Add full text from files."""
ext = current_app.extensions["rero-invenio-files"]
files = []
full_text_size = 0
full_text_size_max = current_app.config.get(
"RERO_ILS_APP_FILES_FULL_TEXT_MAX", 10 * 1024 * 1024
)
for record_file in record.get_records_files():
record_files_information = {}
collections = record_file.get("metadata", {}).get("collections")
Expand All @@ -258,10 +261,12 @@ def _process_files(self, record, data):
continue
if metadata.get("type") == "fulltext":
# get the fulltext
stream = file.get_stream("r")
record_files_information.setdefault(metadata["fulltext_for"], {})[
"text"
] = stream.read()
full_text = file.get_stream("r").read()
full_text_size += len(full_text)
if full_text_size < full_text_size_max:
record_files_information.setdefault(
metadata["fulltext_for"], {}
)["text"] = full_text
continue
# other information from the main file
record_files_information.setdefault(file_name, {})[
Expand Down
10 changes: 8 additions & 2 deletions rero_ils/modules/files/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ class RecordFileServiceConfig(FileServiceConfig):
# Common configuration
permission_policy_cls = FilePermissionPolicy

# maximum files per buckets
max_files_count = 1700
@classmethod
@property
def max_files_count(cls):
"""Maximum files per buckets."""
from flask import current_app

max_ui_files = current_app.config.get("RERO_ILS_APP_FILES_UI_MAX", 600)
return max_ui_files * 3 + 100

# Service components
components = FileServiceConfig.components + [
Expand Down
1 change: 1 addition & 0 deletions rero_ils/modules/patrons/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def logged_user():
data = {
"permissions": expose_actions_need_for_user(),
"settings": {
"maxFilesCount": config.get("RERO_ILS_APP_FILES_UI_MAX", 600),
"language": current_i18n.locale.language,
"globalView": config.get("RERO_ILS_SEARCH_GLOBAL_VIEW_CODE"),
"baseUrl": get_base_url(),
Expand Down
2 changes: 1 addition & 1 deletion tests/api/documents/test_documents_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def check_field_data(key, field_data, data):
"invenio_records_rest.views.verify_record_permission",
mock.MagicMock(return_value=VerifyRecordPermissionPatch),
)
def test_document_fulltext(client, document_with_files, document_with_issn):
def test_document_fulltext(app, client, document_with_files, document_with_issn):
"""Test document with fulltext."""
list_url = url_for(
"invenio_records_rest.doc_list",
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/patrons/test_patrons_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class locale:
== librarian_martigny["libraries"][0]["$ref"].rsplit("/", 1)[-1]
)
assert data.get("settings").get("language") == "fr"
assert data.get("settings").get("globalView") == "global"
assert data.get("settings").get("maxFilesCount") == 600


def test_patron_format_currency_filter(app):
Expand Down
Loading