diff --git a/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v1/aggr-file-download-v1.0.0.json b/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v1/aggr-file-download-v1.0.0.json index 4f256bac2..f386029cd 100644 --- a/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v1/aggr-file-download-v1.0.0.json +++ b/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v1/aggr-file-download-v1.0.0.json @@ -2,7 +2,7 @@ "index_patterns": ["__SEARCH_INDEX_PREFIX__stats-file-download-*"], "settings": { "index": { - "refresh_interval": "1m" + "refresh_interval": "5s" } }, "mappings": { diff --git a/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v2/aggr-file-download-v1.0.0.json b/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v2/aggr-file-download-v1.0.0.json index 4f256bac2..f386029cd 100644 --- a/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v2/aggr-file-download-v1.0.0.json +++ b/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/os-v2/aggr-file-download-v1.0.0.json @@ -2,7 +2,7 @@ "index_patterns": ["__SEARCH_INDEX_PREFIX__stats-file-download-*"], "settings": { "index": { - "refresh_interval": "1m" + "refresh_interval": "5s" } }, "mappings": { diff --git a/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/v7/aggr-file-download-v1.0.0.json b/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/v7/aggr-file-download-v1.0.0.json index 4f256bac2..f386029cd 100644 --- a/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/v7/aggr-file-download-v1.0.0.json +++ b/invenio_rdm_records/records/stats/templates/aggregations/aggr_file_download/v7/aggr-file-download-v1.0.0.json @@ -2,7 +2,7 @@ "index_patterns": ["__SEARCH_INDEX_PREFIX__stats-file-download-*"], "settings": { "index": { - "refresh_interval": "1m" + "refresh_interval": "5s" } }, "mappings": { diff --git a/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v1/aggr-record-view-v1.0.0.json b/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v1/aggr-record-view-v1.0.0.json index 3fdf2775b..a95f812fa 100644 --- a/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v1/aggr-record-view-v1.0.0.json +++ b/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v1/aggr-record-view-v1.0.0.json @@ -2,7 +2,7 @@ "index_patterns": ["__SEARCH_INDEX_PREFIX__stats-record-view-*"], "settings": { "index": { - "refresh_interval": "1m" + "refresh_interval": "5s" } }, "mappings": { diff --git a/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v2/aggr-record-view-v1.0.0.json b/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v2/aggr-record-view-v1.0.0.json index 3fdf2775b..a95f812fa 100644 --- a/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v2/aggr-record-view-v1.0.0.json +++ b/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/os-v2/aggr-record-view-v1.0.0.json @@ -2,7 +2,7 @@ "index_patterns": ["__SEARCH_INDEX_PREFIX__stats-record-view-*"], "settings": { "index": { - "refresh_interval": "1m" + "refresh_interval": "5s" } }, "mappings": { diff --git a/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/v7/aggr-record-view-v1.0.0.json b/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/v7/aggr-record-view-v1.0.0.json index 3fdf2775b..a95f812fa 100644 --- a/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/v7/aggr-record-view-v1.0.0.json +++ b/invenio_rdm_records/records/stats/templates/aggregations/aggr_record_view/v7/aggr-record-view-v1.0.0.json @@ -2,7 +2,7 @@ "index_patterns": ["__SEARCH_INDEX_PREFIX__stats-record-view-*"], "settings": { "index": { - "refresh_interval": "1m" + "refresh_interval": "5s" } }, "mappings": { diff --git a/invenio_rdm_records/services/tasks.py b/invenio_rdm_records/services/tasks.py index 20fa24c81..d1239105b 100644 --- a/invenio_rdm_records/services/tasks.py +++ b/invenio_rdm_records/services/tasks.py @@ -11,6 +11,7 @@ from datetime import datetime, timedelta from celery import shared_task +from celery.schedules import crontab from flask import current_app from invenio_access.permissions import system_identity from invenio_search.engine import dsl @@ -21,9 +22,11 @@ from ..proxies import current_rdm_records from .errors import EmbargoNotLiftedError +# runs every hour at minute 10 for a consistent offset from process and aggregate +# event statistics. StatsRDMReindexTask = { "task": "invenio_rdm_records.services.tasks.reindex_stats", - "schedule": timedelta(hours=1), + "schedule": crontab(minute=10), "args": [ ( "stats-record-view", diff --git a/setup.cfg b/setup.cfg index 8d7c0d4ea..fbbfe50bb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,7 @@ install_requires = invenio-i18n>=2.0.0,<3.0.0 invenio-oaiserver>=2.0.0,<3.0.0 invenio-oauth2server>=2.0.0,<2.1.0 + invenio-stats>=4.0.0,<5.0.0 invenio-vocabularies>=2.0.0,<3.0.0 nameparser>=1.1.1 pytz>=2020.4