-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
global: add support for index templates #148
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,13 @@ | |
|
||
"""Celery background tasks.""" | ||
|
||
from flask import current_app | ||
|
||
from .proxies import current_stats | ||
|
||
|
||
def register_templates(): | ||
"""Register search templates for events.""" | ||
def _collect_templates(): | ||
"""Return event and aggregation templates from config.""" | ||
event_templates = [ | ||
event["templates"] for event in current_stats.events_config.values() | ||
] | ||
|
@@ -21,3 +23,17 @@ def register_templates(): | |
] | ||
|
||
return event_templates + aggregation_templates | ||
|
||
|
||
def register_templates(): | ||
"""Register search templates for events.""" | ||
if current_app.config["STATS_REGISTER_INDEX_TEMPLATES"]: | ||
return [] | ||
return _collect_templates() | ||
|
||
|
||
def register_index_templates(): | ||
"""Register search index templates for events.""" | ||
if not current_app.config["STATS_REGISTER_INDEX_TEMPLATES"]: | ||
return [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these functions look a bit too similar and I am worried they will be easily confusing, but I don't have a good idea on how to avoid this. Maybe a bit more elaborate comments on both to explain the backwards compatibility of |
||
return _collect_templates() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,8 @@ invenio_base.api_blueprints = | |
invenio_stats = invenio_stats.views:blueprint | ||
invenio_search.templates = | ||
invenio_stats = invenio_stats.templates:register_templates | ||
invenio_search.index_templates = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any way of installing one or the other, not both? maybe we need to deprecate |
||
invenio_stats = invenio_stats.templates:register_index_templates | ||
invenio_queues.queues = | ||
invenio_stats = invenio_stats.queues:declare_queues | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it makes sense to show a deprecation warning without having a "way out". Usually these warnings link to some documentation that explains why the change is happening and how to migrate to the new solution (see example below).
I think to move things forward it would be better to cut a minor release, and include this deprecation warning in a new PR that would also include this extra information in the text (and release as a minor/patch).
GH Actions deprecation warning
SQLAlchemy