Skip to content
Open
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
4 changes: 2 additions & 2 deletions modules/weko-workspace/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ def test_get_workspace_filterCon(users, users_index, mock_setup, expected_respon
(
[],
search.TransportError(500, 'Server Error'),
None
[]
),
(
[],
Exception("Unexpected error"),
None
[]
)
])
def test_get_search_itemlist(app, mock_responses, mock_exception, expected_response):
Expand Down
3 changes: 1 addition & 2 deletions modules/weko-workspace/weko_workspace/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""Configuration for weko-workspace."""

from flask_babel import lazy_gettext as _
from invenio_stats.config import SEARCH_INDEX_PREFIX as index_prefix

# Front-end variable definition
WEKO_WORKSPACE_BASE_TEMPLATE = 'weko_workspace/workspace_base.html'
Expand Down Expand Up @@ -288,7 +287,7 @@
}
"""Mapping of OA status to the OA status in WEKO."""

WEKO_WORKSPACE_ITEM_SEARCH_INDEX = "{}-weko".format(index_prefix)
WEKO_WORKSPACE_ITEM_SEARCH_INDEX = "weko"
"""Search index for WEKO workspace item."""

WEKO_WORKSPACE_ITEM_SEARCH_TYPE = "item-v1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<html {% if html_css_classes %} class="{{ html_css_classes|join(' ') }}" {% endif %}
lang="{{ current_i18n.locale.language|safe }}" dir="{{ current_i18n.locale.text_direction }}">
{%- block css %}
{{ webpack["theme-css.scss"] }}
{{ webpack["theme-css.css"] }}
{{ webpack["theme-scss-bootstrap.css"] }}
{{ webpack["theme-css-buttons.css"] }}
{{ webpack["theme-css-widget.css"] }}
{{ webpack["admin_css_weko_admin_quill_snow_css.css"] }}

{{ webpack["workspace_style_css.css"] }}
{{ webpack["workspace_css.css"] }}

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
{%- endblock css %}
Expand All @@ -38,12 +38,12 @@
<script src="/assets/node_modules/react-dom/umd/react-dom.production.min.js" crossorigin></script>

<script type="text/javascript">
window.workspaceItemList = "{{ workspaceItemList | tojson | safe }}";
window.defaultconditions = "{{ defaultconditions | tojson | safe }}";
window.workspaceItemList = {{ workspaceItemList | tojson | safe }};
window.defaultconditions = {{ defaultconditions | tojson | safe }};
</script>

{{ webpack["workspace_item_list_js.js"] }}
<script type="text/javascript" src="static/js/weko_workspace/WorkspaceExport.js"></script>
{{ webpack["workspace_export.js"] }}

{%- endblock js %}

Expand Down
24 changes: 12 additions & 12 deletions modules/weko-workspace/weko_workspace/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_search_itemlist():
size = 10000
search_index = current_app.config["WEKO_WORKSPACE_ITEM_SEARCH_INDEX"]
search_obj = RecordsSearch(index=search_index)
search = search_obj.with_preference_param().params(version=True)
search_query = search_obj.with_preference_param().params(version=True)

# Set the search query
publish_status_match = dsl.Q("terms", publish_status=[
Expand All @@ -162,42 +162,42 @@ def get_search_itemlist():
must = []
must.append(dsl.Q("bool", should=shuld))
must.append(dsl.Q("bool", must=dsl.Q("match", relation_version_is_last="true")))
search = search.filter(dsl.Q("bool", must=must))
search = search.query(dsl.Q("bool", must=dsl.Q("match_all")))
search_query = search_query.filter(dsl.Q("bool", must=must))
search_query = search_query.query(dsl.Q("bool", must=dsl.Q("match_all")))

# Set size / Exclude content field from the source
src = {
"size": size,
"_source": {"excludes": ["content"]}
}
search._extra.update(src)
search_query._extra.update(src)

# Set sorting
search = search.sort("-control_number")
search_query = search_query.sort("-control_number")

# Execute search. Use search_after to retrieve all records
records = []
current_app.logger.debug(f"[workspace] search obj: {search.to_dict()}")
page = search.execute().to_dict()
current_app.logger.debug(f"[workspace] search obj: {search_query.to_dict()}")
page = search_query.execute().to_dict()
current_app.logger.debug(f"[workspace] search result: {page}")
while page.get('hits', {}).get('hits', []):
records.extend(page.get('hits', {}).get('hits', []))
if len(page.get('hits', {}).get('hits', [])) < size:
break
search = search.extra(search_after=page.get('hits', {}).get('hits', [])[-1].get('sort'))
current_app.logger.debug(f"[workspace] search obj: {search.to_dict()}")
page = search.execute().to_dict()
search_query = search_query.extra(search_after=page.get('hits', {}).get('hits', [])[-1].get('sort'))
current_app.logger.debug(f"[workspace] search obj: {search_query.to_dict()}")
page = search_query.execute().to_dict()
current_app.logger.debug(f"[workspace] search result: {page}")
return records

except search.TransportError as e:
traceback.print_exc()
current_app.logger.error(f"Failed to get workflow item list from search: {e} / {search.to_dict()}")
return None
return []
except Exception as e:
traceback.print_exc()
current_app.logger.error(e)
return None
return []


def get_workspace_status_management(recid: str):
Expand Down
1 change: 1 addition & 0 deletions modules/weko-workspace/weko_workspace/webpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"bootstrap3": dict(
entry={
"workspace_item_list_js": "./js/weko_workspace/WorkspaceItemList.js",
"workspace_export": "./js/weko_workspace/WorkspaceExport.js",
"workspace_css": "./css/weko_workspace/WorkspaceBodyContents.css",
"workspace_register_js": "./js/weko_workspace/workspace_register.js",
"workspace_style_css": "./css/weko_workspace/style.css",
Expand Down