Skip to content

Commit

Permalink
statistics: change permission at the library level
Browse files Browse the repository at this point in the history
Migration: need operation logs server side reindex.

* Adds category, indicator, frequence and library facets.
* Changes the stat config update, delete permission at the library level.
* Collects the librarian stats during the setup.
* Adds pickup location distribution for requests.
* Adds owning location distrubution for circulation actions.
* Removes period for ill request report stats.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma committed Nov 20, 2023
1 parent 6b5633c commit 8a0198c
Show file tree
Hide file tree
Showing 35 changed files with 857 additions and 346 deletions.
36 changes: 24 additions & 12 deletions data/role_policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -680,39 +680,48 @@
],
"stat-access": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat-search": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat-read": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat_cfg-access": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat_cfg-search": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat_cfg-read": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat_cfg-create": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat_cfg-update": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"stat_cfg-delete": [
"pro_full_permissions",
"pro_statistic_manager"
"pro_statistic_manager",
"pro_library_administrator"
],
"tmpl-access": [
"pro_full_permissions",
Expand Down Expand Up @@ -831,14 +840,17 @@
],
"locent-update": [
"pro_full_permissions",
"pro_entity_manager"
"pro_entity_manager",
"pro_library_administrator"
],
"locent-create": [
"pro_full_permissions",
"pro_entity_manager"
"pro_entity_manager",
"pro_library_administrator"
],
"locent-delete": [
"pro_full_permissions",
"pro_entity_manager"
"pro_entity_manager",
"pro_library_administrator"
]
}
74 changes: 37 additions & 37 deletions data/stats_cfg.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[
{
"pid": "1",
"name": "organisation 1, no distributions",
"name": "library 1, no distributions",
"description": "Statistics configuration with no distributions",
"category": {
"type": "catalogue",
"indicator": {
"type": "number_of_documents"
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/1"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/1"
},
"frequency": "month",
"is_active": true
},
{
"pid": "2",
"name": "organisation 1, circulation, number of checkouts, time range month",
"name": "library 1, circulation, number of checkouts, time range month",
"description": "Statistics configuration with 1 distribution",
"category": {
"type": "circulation",
Expand All @@ -28,15 +28,15 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/1"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/1"
},
"frequency": "month",
"is_active": true
},
{
"pid": "3",
"name": "organisation 1, number of checkouts, library",
"name": "library 2, number of checkouts, library",
"description": "Statistics configuration with 1 distribution",
"category": {
"type": "circulation",
Expand All @@ -47,15 +47,15 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/1"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/2"
},
"frequency": "month",
"is_active": true
},
{
"pid": "4",
"name": "organisation 1, 2 distributions",
"name": "library 2, 2 distributions",
"description": "Statistics configuration with 2 distributions",
"category": {
"type": "circulation",
Expand All @@ -67,15 +67,15 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/1"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/2"
},
"frequency": "month",
"is_active": true
},
{
"pid": "5",
"name": "organisation 1, 2 distributions, period 1 year",
"name": "library 3, 2 distributions, period 1 year",
"description": "Statistics configuration with 2 distributions",
"category": {
"type": "circulation",
Expand All @@ -88,15 +88,15 @@
"period": "year"
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/1"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/4"
},
"frequency": "month",
"is_active": true
},
{
"pid": "6",
"name": "organisation 1, 2 distributions, status disabled",
"name": "library 3, 2 distributions, status disabled",
"description": "Statistics configuration with 2 distributions",
"category": {
"type": "circulation",
Expand All @@ -108,31 +108,31 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/1"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/4"
},
"frequency": "month",
"is_active": false
},
{
"pid": "7",
"name": "organisation 2, no distributions",
"name": "library 5, no distributions",
"description": "Statistics configuration with no distributions",
"category": {
"type": "catalogue",
"indicator": {
"type": "number_of_documents"
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/2"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/5"
},
"frequency": "month",
"is_active": true
},
{
"pid": "8",
"name": "organisation 2, 1 distribution",
"name": "library 5, 1 distribution",
"description": "Statistics configuration with 1 distribution",
"category": {
"type": "circulation",
Expand All @@ -143,15 +143,15 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/2"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/5"
},
"frequency": "month",
"is_active": true
},
{
"pid": "9",
"name": "organisation 2, 1 distribution",
"name": "library 5, 1 distribution",
"description": "Statistics configuration with 1 distribution",
"category": {
"type": "circulation",
Expand All @@ -162,15 +162,15 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/2"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/5"
},
"frequency": "month",
"is_active": true
},
{
"pid": "10",
"name": "organisation 2, 2 distributions",
"name": "library 5, 2 distributions",
"description": "Statistics configuration with 2 distributions",
"category": {
"type": "circulation",
Expand All @@ -182,15 +182,15 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/2"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/5"
},
"frequency": "month",
"is_active": true
},
{
"pid": "11",
"name": "organisation 2, 2 distributions, period 1 year",
"name": "library 5, 2 distributions, period 1 year",
"description": "Statistics configuration with 2 distributions",
"category": {
"type": "circulation",
Expand All @@ -203,15 +203,15 @@
"period": "year"
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/2"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/5"
},
"frequency": "month",
"is_active": true
},
{
"pid": "12",
"name": "organisation 2, 2 distributions, status disabled",
"name": "library 5, 2 distributions, status disabled",
"description": "Statistics configuration with 1 distribution",
"category": {
"type": "circulation",
Expand All @@ -223,10 +223,10 @@
]
}
},
"organisation": {
"$ref": "https://bib.rero.ch/api/organisations/2"
"library": {
"$ref": "https://bib.rero.ch/api/libraries/5"
},
"frequency": "month",
"is_active": false
}
]
]
3 changes: 2 additions & 1 deletion data/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@
"pro_read_only",
"pro_catalog_manager",
"pro_circulation_manager",
"pro_user_manager"
"pro_user_manager",
"pro_statistic_manager"
],
"libraries": [
{
Expand Down
24 changes: 19 additions & 5 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,12 @@ def _(x):
'json': 'application/json'
},
search_serializers_aliases={
'json': 'application/json'
'json': 'application/json',
'rero+json': 'application/json',
},
search_serializers={
'application/json': 'rero_ils.modules.serializers:json_v1_search'
'application/json': 'rero_ils.modules.serializers:json_v1_search',
'application/rero+json': 'rero_ils.modules.stats_cfg.serializers:json_search'
},
list_route='/stats_cfg/',
record_loaders={
Expand Down Expand Up @@ -2336,11 +2338,23 @@ def _(x):
field='category.type',
size=RERO_ILS_AGGREGATION_SIZE.get(
'stats_cfg', RERO_ILS_DEFAULT_AGGREGATION_SIZE)
),
aggs=dict(
indicator=dict(terms=dict(field='category.indicator.type', size=DOCUMENTS_AGGREGATION_SIZE))
)
)
),
frequency=dict(
terms=dict(field='frequency', size=DOCUMENTS_AGGREGATION_SIZE),

),
library=dict(terms=dict(field='library.pid', size=RERO_ILS_DEFAULT_AGGREGATION_SIZE))
),
filters={
_('category'): and_term_filter('category.type')
_('category'): and_term_filter('category.type'),
_('indicator'): and_term_filter('category.indicator.type'),
_('frequency'): and_term_filter('frequency'),
_('library'): and_term_filter('library.pid'),
_('active'): and_term_filter('is_active')
}
)
)
Expand Down Expand Up @@ -2909,7 +2923,7 @@ def _(x):
template='rero_ils/detailed_view_stats.html',
record_class='rero_ils.modules.stats.api.api:Stat',
view_imp='rero_ils.modules.stats.views.stats_view_method',
permission_factory_imp='rero_ils.permissions.admin_permission_factory',
permission_factory_imp='rero_ils.modules.stats.permissions:stats_ui_permission_factory',
)
}

Expand Down
Loading

0 comments on commit 8a0198c

Please sign in to comment.