From 575c7c7d62bea6adbed36819cba2fc18b748b7c1 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 1 Dec 2022 16:34:14 +0100 Subject: [PATCH] (feat) updated FabAnalytics reports to include new features --- CHANGELOG.md | 1 + .../admin/settings/analyticsModal.html | 9 ++++++++ app/services/health_service.rb | 22 ++++++++++++++----- config/locales/app.admin.en.yml | 9 ++++++++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b0d7072..b3d198759 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog Fab-manager +- Updated FabAnalytics reports to include new features - Fix a bug: setting somes decimal amounts (e.g. 4,85) result in another amount (e.g. 4,84) - Fix a bug: unable to export statistics - Fix a bug: soft destroyed machines and spaces are still reported in the OpenAPI diff --git a/app/frontend/templates/admin/settings/analyticsModal.html b/app/frontend/templates/admin/settings/analyticsModal.html index f8f988d5a..0236e545e 100644 --- a/app/frontend/templates/admin/settings/analyticsModal.html +++ b/app/frontend/templates/admin/settings/analyticsModal.html @@ -9,11 +9,20 @@ {{ 'app.admin.settings.privacy.analytics.version' }}{{ data.version }} {{ 'app.admin.settings.privacy.analytics.members' }}{{ data.members }} {{ 'app.admin.settings.privacy.analytics.admins' }}{{ data.admins }} + {{ 'app.admin.settings.privacy.analytics.managers' }}{{ data.managers }} {{ 'app.admin.settings.privacy.analytics.availabilities' }}{{ data.availabilities }} {{ 'app.admin.settings.privacy.analytics.reservations' }}{{ data.reservations }} + {{ 'app.admin.settings.privacy.analytics.orders' }}{{ data.orders }} {{ 'app.admin.settings.privacy.analytics.plans' }}{{ data.plans }} {{ 'app.admin.settings.privacy.analytics.spaces' }}{{ data.spaces }} {{ 'app.admin.settings.privacy.analytics.online_payment' }}{{ data.online_payment }} + {{ 'app.admin.settings.privacy.analytics.gateway' }}{{ data.gateway }} + {{ 'app.admin.settings.privacy.analytics.wallet' }}{{ data.wallet }} + {{ 'app.admin.settings.privacy.analytics.statistics' }}{{ data.statistics }} + {{ 'app.admin.settings.privacy.analytics.trainings' }}{{ data.trainings }} + {{ 'app.admin.settings.privacy.analytics.public_agenda' }}{{ data.public_agenda }} + {{ 'app.admin.settings.privacy.analytics.machines' }}{{ data.machines }} + {{ 'app.admin.settings.privacy.analytics.store' }}{{ data.store }} {{ 'app.admin.settings.privacy.analytics.invoices' }}{{ data.invoices }} {{ 'app.admin.settings.privacy.analytics.openlab' }}{{ data.openlab }} diff --git a/app/services/health_service.rb b/app/services/health_service.rb index 0c82bbf47..d74047328 100644 --- a/app/services/health_service.rb +++ b/app/services/health_service.rb @@ -12,7 +12,7 @@ class HealthService end def self.redis? - !!Sidekiq.redis(&:info) # rubocop:disable Style/DoubleNegation + !!Sidekiq.redis(&:info) rescue Redis::CannotConnectError false end @@ -22,10 +22,8 @@ class HealthService client = Elasticsearch::Client.new host: "http://#{Rails.application.secrets.elaticsearch_host}:9200" response = client.perform_request 'GET', '_cluster/health' - !!response.body # rubocop:disable Style/DoubleNegation - rescue Elasticsearch::Transport::Transport::Error - false - rescue Faraday::ConnectionFailed + !!response.body + rescue Elasticsearch::Transport::Transport::Error, Faraday::ConnectionFailed false end @@ -39,11 +37,20 @@ class HealthService version: Version.current, members: User.members.count, admins: User.admins.count, + managers: User.managers.count, availabilities: last_week_availabilities, reservations: last_week_new_reservations, + orders: last_week_orders, plans: Setting.get('plans_module'), spaces: Setting.get('spaces_module'), online_payment: Setting.get('online_payment_module'), + gateway: Setting.get('payment_gateway'), + wallet: Setting.get('wallet_module'), + statistics: Setting.get('statistics_module'), + trainings: Setting.get('trainings_module'), + public_agenda: Setting.get('public_agenda_module'), + machines: Setting.get('machines_module'), + store: Setting.get('store_module'), invoices: Setting.get('invoicing_module'), openlab: Setting.get('openlab_app_secret').present? } @@ -74,5 +81,8 @@ class HealthService def self.last_week_new_reservations Reservation.where('created_at >= ? AND created_at < ?', DateTime.current - 7.days, DateTime.current).count end -end + def self.last_week_orders + Order.where('created_at >= ? AND created_at < ?', DateTime.current - 7.days, DateTime.current).where.not(state: 'cart').count + end +end diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 7419041eb..93303b1fd 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -1653,11 +1653,20 @@ en: version: "Application version" members: "Number of members" admins: "Number of administrators" + managers: "Number of managers" availabilities: "Number of availabilities of the last 7 days" reservations: "Number of reservations during the last 7 days" + orders: "Number of store orders during the last 7 days" plans: "Is the subscription module active?" spaces: "Is the space management module active?" online_payment: "Is the online payment module active?" + gateway: "The payment gateway used to collect online payments" + wallet: "Is the wallet module active?" + statistics: "Is the statistics module active?" + trainings: "Is the trainings module active?" + public_agenda: "Is the public_agenda module active?" + machines: "Is the machines module active?" + store: "Is the store module active?" invoices: "Is the invoicing module active?" openlab: "Is the project sharing module (OpenLab) active?" tracking_id_info_html: "To enable the statistical tracking of the visits using Google Analytics V4, set your tracking ID here. It is in the form G-XXXXXX. Visit the Google Analytics website to get one.
Warning: if you enable this feature, a cookie will be created. Remember to write it down in your privacy policy, above."