Skip to content

Commit

Permalink
add control over prophet library (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh authored Aug 25, 2023
1 parent e418393 commit 6f60fe0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions app/views/home/_case_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
</p>
<!-- Look at https://github.com/ankane/prophet-ruby -->
<%
#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] }
data = data.map {|h| h.transform_keys(&:to_s) }

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)
Expand Down
5 changes: 5 additions & 0 deletions config/initializers/customize_quepid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
1 change: 1 addition & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions docs/operating_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 6f60fe0

Please sign in to comment.