# Path: invenio_stats/utils.py
# def default_permission_factory(query_name, params):
#     """Default permission factory.
# 
#     It enables by default the statistics if they don't have a dedicated
#     permission factory.
#     """
#     from invenio_stats import current_stats
#     if current_stats.queries[query_name].permission_factory is None:
#         return AllowAllPermission
#     else:
#         return current_stats.queries[query_name].permission_factory(
#             query_name, params
#         )


from kombu import Exchange
from .utils import default_permission_factory
"""

STATS_EVENTS = {}
"""Enabled Events.

Each key is the name of an event. A queue will be created for each event.

If the dict of an event contains the ``signal`` key, and the config variable
``STATS_REGISTER_RECEIVERS`` is ``True``, a signal receiver will be registered.
Receiver function which will be connected on a signal and emit events. The key
is the name of the emitted event.

``signal``: Signal to which the receiver will be connected to.

``event_builders``: list of functions which will create and enhance the event.
    Each function will receive the event created by the previous function and
    can update it. Keep in mind that these functions will run synchronously
    during the creation of the event, meaning that if the signal is sent during
    a request they will increase the response time.

You can find a sampe of STATS_EVENT configuration in the `registrations.py`
"""


STATS_AGGREGATIONS = {}


STATS_QUERIES = {}



# Path: invenio_stats/utils.py
# def default_permission_factory(query_name, params):
#     """Default permission factory.
# 
#     It enables by default the statistics if they don't have a dedicated
#     permission factory.
#     """
#     from invenio_stats import current_stats
#     if current_stats.queries[query_name].permission_factory is None:
#         return AllowAllPermission
#     else:
#         return current_stats.queries[query_name].permission_factory(
#             query_name, params
#         )


# Path: invenio_stats/config.py
from kombu import Exchange
from .utils import default_permission_factory

"""

STATS_EVENTS = {}
"""Enabled Events.

Each key is the name of an event. A queue will be created for each event.

If the dict of an event contains the ``signal`` key, and the config variable
``STATS_REGISTER_RECEIVERS`` is ``True``, a signal receiver will be registered.
Receiver function which will be connected on a signal and emit events. The key
is the name of the emitted event.

``signal``: Signal to which the receiver will be connected to.

``event_builders``: list of functions which will create and enhance the event.
    Each function will receive the event created by the previous function and
    can update it. Keep in mind that these functions will run synchronously
    during the creation of the event, meaning that if the signal is sent during
    a request they will increase the response time.

You can find a sampe of STATS_EVENT configuration in the `registrations.py`
"""


STATS_AGGREGATIONS = {}


STATS_QUERIES = {}



STATS_PERMISSION_FACTORY = default_permission_factory