From 6f60fe0ad8f54804b3f7dc55041198c615bcdd4f Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Fri, 25 Aug 2023 10:17:54 -0400 Subject: [PATCH] add control over prophet library (#799) --- .env.example | 3 +++ app/views/home/_case_summary.html.erb | 3 +-- config/initializers/customize_quepid.rb | 5 +++++ docker-compose.prod.yml | 1 + docs/operating_documentation.md | 12 ++++++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 6817eb98d..6c6a4fd03 100644 --- a/.env.example +++ b/.env.example @@ -60,3 +60,6 @@ GOOGLE_CLIENT_SECRET=your_google_client_secret KEYCLOAK_REALM=quepid KEYCLOAK_SITE=http://keycloak:9080 + +# Whether or not to do analytics for interesting events in Case Scores +QUEPID_PROPHET_ANALYTICS=true diff --git a/app/views/home/_case_summary.html.erb b/app/views/home/_case_summary.html.erb index d978a2470..d2955ae20 100644 --- a/app/views/home/_case_summary.html.erb +++ b/app/views/home/_case_summary.html.erb @@ -10,7 +10,6 @@

<% - #df = Rover.read_csv("example.csv") data = kase.scores.collect{ |score| {ds: score.created_at.to_date.to_fs(:db), y: score.score, datetime: score.created_at.to_date } }.uniq # warning! blunt filter below! data = data.uniq { |h| h[:ds] } @@ -18,7 +17,7 @@ do_changepoints = data.length >= 3 ? true : false # need at least 3... - if do_changepoints + if Rails.application.config.quepid_prophet_analytics && do_changepoints df = Rover::DataFrame.new(data) m = Prophet.new() m.fit(df) diff --git a/config/initializers/customize_quepid.rb b/config/initializers/customize_quepid.rb index ac2c2164e..8338b9553 100644 --- a/config/initializers/customize_quepid.rb +++ b/config/initializers/customize_quepid.rb @@ -94,3 +94,8 @@ # == Disable redirecting to match the TLS setting Rails.application.config.redirect_to_match_search_engine_tls = ENV.fetch('REDIRECT_TO_MATCH_SEARCH_ENGINE_TLS', true) + +# == Prophet Analytics Control +# Prophet tells you interesting things about time series curves and is used on the homepage. +# It may consume too much memory for your environment, and you may need to disable it. +Rails.application.config.quepid_prophet_analytics = bool.deserialize(ENV.fetch('QUEPID_PROPHET_ANALYTICS', true)) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 6a3ceaa82..8fce11645 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -46,6 +46,7 @@ services: - EMAIL_PROVIDER= - EMAIL_SENDER= - QUERY_LIST_SORTABLE=true + - QUEPID_PROPHET_ANALYTICS=true command: "foreman s -f Procfile" ports: # - 80:3000 # Map to port 80 for outside users when you are not using Nginx diff --git a/docs/operating_documentation.md b/docs/operating_documentation.md index afa6deb1a..abe5adb33 100644 --- a/docs/operating_documentation.md +++ b/docs/operating_documentation.md @@ -9,6 +9,7 @@ This document explains how Quepid can be operated and configured. - [Legal Pages & GDPR](#legal-pages-&-gdpr) - [User Tracking](#user-tracking) - [Heathcheck Endpoint](#healthcheck) +- [Analytics Settings](#analytics-settings) - [Troubleshoot Your Deploy](#troubleshoot-your-deploy) - [Database Management](#database-management) - [Jupyterlite Notebooks](#jupyterlite-notebooks) @@ -174,6 +175,17 @@ the file `Procfile` Want to monitor if Quepid is behaving? Just monitor `/healthcheck`, and you will get 200 status codes from a healthy Quepid, and 503 if not. The JSON output is `{"code":200,"status":{"database":"OK","migrations":"OK"}}`. +## Analytics Settings + +We use the [Prophet.rb](https://github.com/ankane/prophet-ruby) library to decide when interesting things happen in our case scores on the homepage. +This library may use too much memory for your deploy, and can be disabled. + +You can disable this behavior by setting the follow `ENV` var: + +``` +QUEPID_PROPHET_ANALYTICS=false +``` + ## Troubleshoot Your Deploy When errors occur, Quepid logs them and shows a generic page.