Skip to content

Commit

Permalink
Merge pull request #56 from LD4P/customizations
Browse files Browse the repository at this point in the history
Allow QA and QaServer customizations to be set using Rails ENV variables
  • Loading branch information
elrayle committed Mar 29, 2022
2 parents 2e24e86 + 4bac86c commit fd12030
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
24 changes: 22 additions & 2 deletions .env.example
Expand Up @@ -13,8 +13,6 @@ RAILS_ENV=development
## Do not keep production secrets in the unencrypted secrets file.
SECRET_KEY_BASE=CHANGEME

## Used to control launch of long-running processes from the browser.
RELOAD_TOKEN=CHANGEME

MAX_PERFORMANCE_CACHE_SIZE=8MB

Expand Down Expand Up @@ -54,3 +52,25 @@ MYSQL_POOL=5
MYSQL_USER=CHANGEME
MYSQL_PASSWORD=CHANGEME
MYSQL_ROOT_PASSWORD=CHANGEME

## --------------------
## QA_SERVER CUSTOMIZATIONS
## --------------------
PREFERRED_TIME_ZONE_NAME=Eastern Time (US & Canada)
DISPLAY_HISTORICAL_DATA=true
HISTORICAL_DATA_DEFAULT_TIME_PERIOD=:month
DISPLAY_PERFORMANCE_GRAPH=false
DISPLAY_PERFORMANCE_DATATABLE=false
PERFORMANCE_DATA_DEFAULT_TIME_PERIOD=:month
SUPPRESS_PERFORMANCE_LOGGING=true
MONITOR_STATUS_LOGGING_ENABLED=false

## --------------------
## QA CUSTOMIZATIONS
## --------------------
ENABLE_CORS_HEADERS=true
DEFAULT_LANGUAGE=:en
SUPPRESS_IP_DATA_FROM_LOG=true

## Used to control launch of long-running processes from the browser.
RELOAD_TOKEN=CHANGEME
7 changes: 3 additions & 4 deletions config/initializers/qa.rb
Expand Up @@ -2,8 +2,7 @@
# When enabled, CORS headers will be added to the responses for search and show. `OPTIONS` method will also be supported.
# Uncomment one of the lines below to enable or disable CORS headers. This configuration defaults to disabled when not set.
# More information on CORS headers at: https://fetch.spec.whatwg.org/#cors-protocol
config.enable_cors_headers
# config.disable_cors_headers
ENV['ENABLE_CORS_HEADERS'] ? config.enable_cors_headers : config.disable_cors_headers

# Provide a token that allows reloading of linked data authorities through the controller
# action '/reload/linked_data/authorities?auth_token=YOUR_AUTH_TOKEN_DEFINED_HERE' without
Expand All @@ -13,7 +12,7 @@

# For linked data access, specify default language for sorting and selection. The default is only used if a language is not
# specified in the authority's configuration file and not passed in as a parameter. (e.g. :en, [:en], or [:en, :fr])
config.default_language = :en
config.default_language = ENV['DEFAULT_LANGUAGE'].to_sym || :en

# When true, prevents ldpath requests from making additional network calls. All values will come from the context graph
# passed to the ldpath request.
Expand All @@ -27,5 +26,5 @@
# IP data including IP address, city, state, and country will be logged with each request.
# When false, IP data is logged
# When true, IP data will not be logged (default for backward compatibility)
config.suppress_ip_data_from_log = false
config.suppress_ip_data_from_log = ActiveModel::Type::Boolean.new.cast(ENV['SUPPRESS_IP_DATA_FROM_LOG']) || true
end
23 changes: 11 additions & 12 deletions config/initializers/qa_server.rb
Expand Up @@ -3,7 +3,7 @@
# Preferred time zone for reporting historical data and performance data
# @param [String] time zone name
# @see https://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html for possible values of TimeZone names
config.preferred_time_zone_name = 'Eastern Time (US & Canada)'
config.preferred_time_zone_name = ENV['PREFERRED_TIME_ZONE_NAME'] || 'Eastern Time (US & Canada)'

# Preferred hour to expire caches related to slow running calculations (e.g. monitoring tests, performance data)
# @param [Integer] count of hours from midnight (0-23 with 0=midnight)
Expand All @@ -18,27 +18,27 @@

# Displays a datatable of historical test data when true
# @param [Boolean] display history datatable when true
config.display_historical_datatable = true
config.display_historical_datatable = ActiveModel::Type::Boolean.new.cast(ENV['DISPLAY_HISTORICAL_DATA'] || true)

# Historical datatable default time period.
# @param [Symbol] time period for calculating historical pass/fail (i.e., one of :month, :year, or :all)
config.historical_datatable_default_time_period = :year
config.historical_datatable_default_time_period = ENV['HISTORICAL_DATA_DEFAULT_TIME_PERIOD'].to_sym || :year

# Displays a graph of performance test data when true
# @param [Boolean] display performance graph when true
config.display_performance_graph = false
config.display_performance_graph = ActiveModel::Type::Boolean.new.cast(ENV['DISPLAY_PERFORMANCE_GRAPH'] || false)

# Displays a datatable of performance test data when true
# @param [Boolean] display performance datatable when true
config.display_performance_datatable = true
config.display_performance_datatable = ActiveModel::Type::Boolean.new.cast(ENV['DISPLAY_PERFORMANCE_DATATABLE'] || true)

# Performance graph default time period for all graphs. All authorities will show the graph for this time period on page load.
# @param [String] :day, :month, or :year
config.performance_graph_default_time_period = :month
config.performance_graph_default_time_period = ENV['PERFORMANCE_DATA_DEFAULT_TIME_PERIOD'].to_sym || :month

# Performance datatable default time period for calculating stats.
# @param [String] :day, :month, :year, :all
config.performance_datatable_default_time_period = :year
config.performance_datatable_default_time_period = ENV['PERFORMANCE_DATA_DEFAULT_TIME_PERIOD'].to_sym || :month

# Max time in milliseconds for y-axis in the performance graphs.
# @param [Integer] milliseconds
Expand Down Expand Up @@ -76,12 +76,12 @@
# Performance data is gathered on every incoming query. If load is high, this can have a negative performance
# impact and may need to be suppressed. Performance stats will not be gathered when this config is true.
# @param [Boolean] do not gather performance data when true (defaults to false for backward compatibitily)
config.suppress_performance_gathering = false
config.suppress_performance_gathering = ActiveModel::Type::Boolean.new.cast(ENV['SUPPRESS_PERFORMANCE_LOGGING'] || true)

# Performance data is gathered on every incoming query. Basic stats are logged from QA. Full stats are logged
# by QaServer and can eat up logging realestate. To suppress the logging of details, set this config to true.
# @param [Boolean] do not log performance data details when true (defaults to false for backward compatibitily)
config.suppress_logging_performance_datails = true
config.suppress_logging_performance_details = ActiveModel::Type::Boolean.new.cast(ENV['SUPPRESS_PERFORMANCE_LOGGING'] || true)

# Maximum amount of memory the performance cache can occupy before it is written to the database.
# @param [Integer] maximum size of performance cache before flushing
Expand All @@ -92,13 +92,12 @@
# default levels for Rails loggers (i.e. enabled for development, disabled for production.)
# config.enable_performance_cache_logging
# config.disable_performance_cache_logging
config.enable_performance_cache_logging if ActiveModel::Type::Boolean.new.cast(ENV['PERFORMANCE_CACHE_LOGGING_ENABLED'] || false)

# Enable/Disable logging of monitoring process
# Uncomment one of the lines below to enable or disable monitoring process logging. NOTE: By default, loggers follow the
# default levels for Rails loggers (i.e. enabled for development, disabled for production.)
# config.enable_monitor_status_logging
# config.disable_monitor_status_logging

config.enable_monitor_status_logging if ENV['MONITOR_STATUS_LOGGING_ENABLED']
config.enable_performance_cache_logging if ENV['PERFORMANCE_CACHE_LOGGING_ENABLED']
config.enable_monitor_status_logging if ActiveModel::Type::Boolean.new.cast(ENV['MONITOR_STATUS_LOGGING_ENABLED'] || false)
end
4 changes: 2 additions & 2 deletions config/locales/qa_server_container.en.yml
Expand Up @@ -4,6 +4,6 @@ en:
application_version: "0.1.0"
application_name: "Authority Lookup Service"
footer:
copyright_html: "<strong>Copyright &copy; 2018-2020 Cornell</strong> Licensed under the Apache License, Version 2.0"
service_html: A service of <a href="http://www.library.cornell.edu/" class="navbar-link" target="_blank">Cornell University Library</a> and <br /><a href="https://www.slis.uiowa.edu/" class="navbar-link" target="_blank">School of Library and Information Science, University of Iowa</a>.
copyright_html: "<strong>Copyright &copy; 2018-2022 Cornell</strong> Licensed under the Apache License, Version 2.0"
service_html: A service of YOUR INSTITUTION.
attribution_html: This service is supported by work on <a href="http://ld4p.org" class="navbar-link" target="_blank">Linked Data for Production</a> and <br> <a href="https://wiki.duraspace.org/x/9xgRBg" class="navbar-link" target="_blank">Linked Data for Production</a> funded by <a href="https://mellon.org/" class="navbar-link" target="_blank">The Andrew W. Mellon Foundation</a>, <br>and by work on Questioning Authority in <a href="http://samvera.org" class="navbar-link" target="_blank">Samvera</a>, an open source community.

0 comments on commit fd12030

Please sign in to comment.