From 33f2a8722a702fcdce5fe90ed97d79f4766a48e6 Mon Sep 17 00:00:00 2001
From: Rob Sanheim
Date: Mon, 24 Aug 2020 13:52:15 -0500
Subject: [PATCH] Various reports fixes (#1240)
* Show less months in the dropdown
* A bit less top padding for charts
* tests for to_s
* Adjust month formatting to Mon-Year
* Update standard, apply fixes that can auto apply
* Ensure we call super so parent classes can initialize
This is required to make the latest version of standard happy
See https://github.com/rubocop-hq/ruby-style-guide/issues/809
and https://github.com/rubocop-hq/rubocop/pull/8376 for context
* More linting fixes
* Bump cache versions
Just incase the date formatting change happens to mess w/ our cache keys
* Fix the keys to match the new period formatting
* Updated overview card chart spacing
Co-authored-by: claudiovallejo
---
Gemfile.lock | 26 +++++++++++--------
app/assets/javascripts/reports.js | 6 ++---
app/assets/stylesheets/partials/_reports.scss | 1 +
app/jobs/anonymized_data_download_job.rb | 4 +--
.../cohort_report/facility_group_policy.rb | 1 +
app/policies/cohort_report/facility_policy.rb | 1 +
.../cohort_report/organization_policy.rb | 1 +
app/policies/cohort_report/user_policy.rb | 1 +
.../manage/admin/facility_group_policy.rb | 1 +
app/policies/manage/admin/facility_policy.rb | 1 +
.../manage/admin/organization_policy.rb | 1 +
app/policies/manage/admin/user_policy.rb | 1 +
.../manage/facility/facility_group_policy.rb | 1 +
.../manage/facility/facility_policy.rb | 1 +
.../manage/facility/organization_policy.rb | 1 +
app/policies/manage/facility_group_policy.rb | 1 +
app/policies/manage/organization_policy.rb | 1 +
app/policies/manage/protocol_drug_policy.rb | 1 +
app/policies/manage/protocol_policy.rb | 1 +
app/policies/manage/user/facility_policy.rb | 1 +
app/policies/manage/user/user_policy.rb | 1 +
.../overdue_list/appointment_policy.rb | 1 +
app/policies/overdue_list/facility_policy.rb | 1 +
app/policies/overdue_list/patient_policy.rb | 1 +
.../overdue_list/patient_summary_policy.rb | 1 +
.../my_facilities/missed_visits_query.rb | 4 +--
.../my_facilities/registrations_query.rb | 6 ++---
app/services/control_rate_service.rb | 2 +-
app/services/region_report_service.rb | 2 +-
app/views/reports/regions/_header.html.erb | 2 +-
app/views/reports/regions/show.html.erb | 16 ++++++------
config/environments/production.rb | 2 +-
config/initializers/time_and_date_formats.rb | 4 +--
config/puma.rb | 4 +--
lib/loggers/api_usage_logger.rb | 2 +-
lib/tasks/dell_demo.rake | 2 +-
spec/models/period_spec.rb | 7 ++++-
spec/services/region_report_service_spec.rb | 8 +++---
38 files changed, 75 insertions(+), 44 deletions(-)
diff --git a/Gemfile.lock b/Gemfile.lock
index e0d938dd45..41159d032f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -51,7 +51,7 @@ GEM
airbrussh (1.4.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (9.0.0)
- ast (2.4.0)
+ ast (2.4.1)
auto_strip_attributes (2.6.0)
activerecord (>= 4.0)
autoprefixer-rails (9.7.6)
@@ -270,11 +270,11 @@ GEM
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.5.0)
- parallel (1.19.1)
+ parallel (1.19.2)
parallel_tests (2.32.0)
parallel
- parser (2.7.1.2)
- ast (~> 2.4.0)
+ parser (2.7.1.4)
+ ast (~> 2.4.1)
passenger (6.0.4)
rack
rake (>= 0.8.1)
@@ -419,15 +419,19 @@ GEM
rswag-ui (1.6.0)
actionpack (>= 3.1, < 6.0)
railties (>= 3.1, < 6.0)
- rubocop (0.83.0)
+ rubocop (0.89.1)
parallel (~> 1.10)
- parser (>= 2.7.0.1)
+ parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
+ regexp_parser (>= 1.7)
rexml
+ rubocop-ast (>= 0.3.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
- rubocop-performance (1.5.2)
- rubocop (>= 0.71.0)
+ rubocop-ast (0.3.0)
+ parser (>= 2.7.1.4)
+ rubocop-performance (1.7.1)
+ rubocop (>= 0.82.0)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.10.1)
@@ -481,9 +485,9 @@ GEM
net-ssh (>= 2.8.0)
sshkit-interactive (0.3.0)
sshkit (~> 1.12)
- standard (0.4.2)
- rubocop (~> 0.83.0)
- rubocop-performance (~> 1.5.2)
+ standard (0.5.1)
+ rubocop (~> 0.89.1)
+ rubocop-performance (~> 1.7.1)
strong_password (0.0.8)
thor (0.20.3)
thread_safe (0.3.6)
diff --git a/app/assets/javascripts/reports.js b/app/assets/javascripts/reports.js
index ca1937123b..1ecf781bff 100644
--- a/app/assets/javascripts/reports.js
+++ b/app/assets/javascripts/reports.js
@@ -206,7 +206,7 @@ function createGraphOptions(isStacked, stepSize, suggestedMax, tickCallbackFunct
padding: {
left: 0,
right: 0,
- top: 48,
+ top: 20,
bottom: 0
}
},
@@ -235,7 +235,7 @@ function createGraphOptions(isStacked, stepSize, suggestedMax, tickCallbackFunct
maxRotation: 0,
minRotation: 0,
autoSkip: true,
- maxTicksLimit: 10
+ maxTicksLimit: 10
}
}],
yAxes: [{
@@ -270,7 +270,7 @@ function createGraphOptions(isStacked, stepSize, suggestedMax, tickCallbackFunct
xPadding: 10,
yPadding: 10,
itemSort: function (a, b) {
- return b.datasetIndex - a.datasetIndex;
+ return b.datasetIndex - a.datasetIndex;
},
callbacks: {
label: function (tooltipItem, data) {
diff --git a/app/assets/stylesheets/partials/_reports.scss b/app/assets/stylesheets/partials/_reports.scss
index d1c6b238da..2bee3bdbe8 100644
--- a/app/assets/stylesheets/partials/_reports.scss
+++ b/app/assets/stylesheets/partials/_reports.scss
@@ -49,6 +49,7 @@
.pt-4px { padding-top: 4px; }
.pt-20px { padding-top: 20px; }
.pt-24px { padding-top: 24px; }
+.pb-4px { padding-bottom: 4px; }
.pb-8px { padding-bottom: 8px; }
.pl-16px { padding-left: 16px; }
.px-1px { padding-right: 1px; padding-left: 1px; }
diff --git a/app/jobs/anonymized_data_download_job.rb b/app/jobs/anonymized_data_download_job.rb
index 31c6f7c6c6..37b8beebf0 100644
--- a/app/jobs/anonymized_data_download_job.rb
+++ b/app/jobs/anonymized_data_download_job.rb
@@ -4,12 +4,12 @@ class AnonymizedDataDownloadJob < ApplicationJob
def perform(recipient_name, recipient_email, model_params_map, model_type)
case model_type
- when "district" then
+ when "district"
AnonymizedData::DownloadService.new.run_for_district(recipient_name,
recipient_email,
model_params_map[:district_name],
model_params_map[:organization_id])
- when "facility" then
+ when "facility"
AnonymizedData::DownloadService.new.run_for_facility(recipient_name,
recipient_email,
model_params_map[:facility_id])
diff --git a/app/policies/cohort_report/facility_group_policy.rb b/app/policies/cohort_report/facility_group_policy.rb
index 1ffce29097..f4f895b75f 100644
--- a/app/policies/cohort_report/facility_group_policy.rb
+++ b/app/policies/cohort_report/facility_group_policy.rb
@@ -3,6 +3,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/cohort_report/facility_policy.rb b/app/policies/cohort_report/facility_policy.rb
index 3ad3121ac7..05cd232823 100644
--- a/app/policies/cohort_report/facility_policy.rb
+++ b/app/policies/cohort_report/facility_policy.rb
@@ -35,6 +35,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/cohort_report/organization_policy.rb b/app/policies/cohort_report/organization_policy.rb
index 60b8f9d73c..c3c138f28c 100644
--- a/app/policies/cohort_report/organization_policy.rb
+++ b/app/policies/cohort_report/organization_policy.rb
@@ -7,6 +7,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/cohort_report/user_policy.rb b/app/policies/cohort_report/user_policy.rb
index a8a6dcfd7e..5e3069c933 100644
--- a/app/policies/cohort_report/user_policy.rb
+++ b/app/policies/cohort_report/user_policy.rb
@@ -3,6 +3,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/admin/facility_group_policy.rb b/app/policies/manage/admin/facility_group_policy.rb
index 55b6bc1813..20ca06c4dc 100644
--- a/app/policies/manage/admin/facility_group_policy.rb
+++ b/app/policies/manage/admin/facility_group_policy.rb
@@ -3,6 +3,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/admin/facility_policy.rb b/app/policies/manage/admin/facility_policy.rb
index 947daf84e1..3bf72c2bf4 100644
--- a/app/policies/manage/admin/facility_policy.rb
+++ b/app/policies/manage/admin/facility_policy.rb
@@ -3,6 +3,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/admin/organization_policy.rb b/app/policies/manage/admin/organization_policy.rb
index 98239fe7ab..1e42ba16cb 100644
--- a/app/policies/manage/admin/organization_policy.rb
+++ b/app/policies/manage/admin/organization_policy.rb
@@ -3,6 +3,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/admin/user_policy.rb b/app/policies/manage/admin/user_policy.rb
index 4b839ec9af..ff2f83f9f5 100644
--- a/app/policies/manage/admin/user_policy.rb
+++ b/app/policies/manage/admin/user_policy.rb
@@ -47,6 +47,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/facility/facility_group_policy.rb b/app/policies/manage/facility/facility_group_policy.rb
index 9fe09ddb49..82fbb71115 100644
--- a/app/policies/manage/facility/facility_group_policy.rb
+++ b/app/policies/manage/facility/facility_group_policy.rb
@@ -9,6 +9,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/facility/facility_policy.rb b/app/policies/manage/facility/facility_policy.rb
index e1f0afed05..5910f1a79e 100644
--- a/app/policies/manage/facility/facility_policy.rb
+++ b/app/policies/manage/facility/facility_policy.rb
@@ -55,6 +55,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/facility/organization_policy.rb b/app/policies/manage/facility/organization_policy.rb
index 37ad294910..8eb068207d 100644
--- a/app/policies/manage/facility/organization_policy.rb
+++ b/app/policies/manage/facility/organization_policy.rb
@@ -3,6 +3,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/facility_group_policy.rb b/app/policies/manage/facility_group_policy.rb
index c54469a327..2007b301ee 100644
--- a/app/policies/manage/facility_group_policy.rb
+++ b/app/policies/manage/facility_group_policy.rb
@@ -49,6 +49,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/organization_policy.rb b/app/policies/manage/organization_policy.rb
index eaa53c3bc6..d2b566f3d5 100644
--- a/app/policies/manage/organization_policy.rb
+++ b/app/policies/manage/organization_policy.rb
@@ -45,6 +45,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/protocol_drug_policy.rb b/app/policies/manage/protocol_drug_policy.rb
index 61c7280e9e..3dbc893c71 100644
--- a/app/policies/manage/protocol_drug_policy.rb
+++ b/app/policies/manage/protocol_drug_policy.rb
@@ -33,6 +33,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/protocol_policy.rb b/app/policies/manage/protocol_policy.rb
index 57003d0c53..8b92fdfb67 100644
--- a/app/policies/manage/protocol_policy.rb
+++ b/app/policies/manage/protocol_policy.rb
@@ -31,6 +31,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/user/facility_policy.rb b/app/policies/manage/user/facility_policy.rb
index bfbb436af0..e026356bb3 100644
--- a/app/policies/manage/user/facility_policy.rb
+++ b/app/policies/manage/user/facility_policy.rb
@@ -3,6 +3,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/manage/user/user_policy.rb b/app/policies/manage/user/user_policy.rb
index 45bee1c094..fd7666e64a 100644
--- a/app/policies/manage/user/user_policy.rb
+++ b/app/policies/manage/user/user_policy.rb
@@ -41,6 +41,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/overdue_list/appointment_policy.rb b/app/policies/overdue_list/appointment_policy.rb
index 72bec659e5..dffe22b694 100644
--- a/app/policies/overdue_list/appointment_policy.rb
+++ b/app/policies/overdue_list/appointment_policy.rb
@@ -19,6 +19,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/overdue_list/facility_policy.rb b/app/policies/overdue_list/facility_policy.rb
index b0c64c9841..1e1b63274a 100644
--- a/app/policies/overdue_list/facility_policy.rb
+++ b/app/policies/overdue_list/facility_policy.rb
@@ -11,6 +11,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/overdue_list/patient_policy.rb b/app/policies/overdue_list/patient_policy.rb
index 1d8ea82b87..be6842560d 100644
--- a/app/policies/overdue_list/patient_policy.rb
+++ b/app/policies/overdue_list/patient_policy.rb
@@ -7,6 +7,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/policies/overdue_list/patient_summary_policy.rb b/app/policies/overdue_list/patient_summary_policy.rb
index 7a5f0f469f..cbde21b57d 100644
--- a/app/policies/overdue_list/patient_summary_policy.rb
+++ b/app/policies/overdue_list/patient_summary_policy.rb
@@ -7,6 +7,7 @@ class Scope < Scope
attr_reader :user, :scope
def initialize(user, scope)
+ super
@user = user
@scope = scope
end
diff --git a/app/queries/my_facilities/missed_visits_query.rb b/app/queries/my_facilities/missed_visits_query.rb
index 99be310331..471f61a7cf 100644
--- a/app/queries/my_facilities/missed_visits_query.rb
+++ b/app/queries/my_facilities/missed_visits_query.rb
@@ -85,9 +85,9 @@ def total_registrations
def period_list(period, last_n)
case period
- when :quarter then
+ when :quarter
last_n_quarters(n: last_n, inclusive: false)
- when :month then
+ when :month
last_n_months(n: last_n, inclusive: false)
.map { |month| [month.year, month.month] }
end
diff --git a/app/queries/my_facilities/registrations_query.rb b/app/queries/my_facilities/registrations_query.rb
index d852e84aba..6a301a7567 100644
--- a/app/queries/my_facilities/registrations_query.rb
+++ b/app/queries/my_facilities/registrations_query.rb
@@ -35,12 +35,12 @@ def total_registrations
def period_list(period, last_n)
case period
- when :quarter then
+ when :quarter
last_n_quarters(n: last_n, inclusive: true)
- when :month then
+ when :month
last_n_months(n: last_n, inclusive: true)
.map { |month| [month.year, month.month] }
- when :day then
+ when :day
last_n_days(n: last_n)
end
end
diff --git a/app/services/control_rate_service.rb b/app/services/control_rate_service.rb
index 7bbe04ebc2..2acfeb6bd0 100644
--- a/app/services/control_rate_service.rb
+++ b/app/services/control_rate_service.rb
@@ -1,5 +1,5 @@
class ControlRateService
- CACHE_VERSION = 7
+ CACHE_VERSION = 8
# Can be initialized with _either_ a Period range or a single Period to calculate
# control rates. We need to handle a single period for calculating point in time benchmarks.
diff --git a/app/services/region_report_service.rb b/app/services/region_report_service.rb
index 60eacb207c..f8c995c449 100644
--- a/app/services/region_report_service.rb
+++ b/app/services/region_report_service.rb
@@ -1,7 +1,7 @@
class RegionReportService
include SQLHelpers
MAX_MONTHS_OF_DATA = 24
- CACHE_VERSION = 7
+ CACHE_VERSION = 8
def initialize(region:, period:, current_user:, top_region_benchmarks_enabled: false)
@current_user = current_user
diff --git a/app/views/reports/regions/_header.html.erb b/app/views/reports/regions/_header.html.erb
index 28b007089f..989b84507b 100644
--- a/app/views/reports/regions/_header.html.erb
+++ b/app/views/reports/regions/_header.html.erb
@@ -49,7 +49,7 @@
<%= form_for(@period, url: request.params, method: :get, enforce_utf8: false) do |f| %>
<%= f.hidden_field :type, { id: "dropdown-period-type" } %>
- <% (1..13).each do |num|
+ <% (1..6).each do |num|
selected = false
date = Date.current.beginning_of_month.advance(months: -num)
period = Period.new(type: :month, value: date)
diff --git a/app/views/reports/regions/show.html.erb b/app/views/reports/regions/show.html.erb
index 17542735ed..894ab4a09b 100644
--- a/app/views/reports/regions/show.html.erb
+++ b/app/views/reports/regions/show.html.erb
@@ -12,7 +12,7 @@
HTN patients with BP <140/90 at their most recent visit in the last 3 months
-
+
<% if @data.last_value(:controlled_patients_rate) %>
<%= number_to_percentage(@data.last_value(:controlled_patients_rate), precision: 0) %>
@@ -37,7 +37,7 @@
-
+
-
+
@@ -114,7 +114,7 @@
HTN patients with BP ≥140/90 at their most recent visit in the last 3 months
-
+
<% if @data.last_value(:uncontrolled_patients_rate) %>
<%= number_to_percentage(@data.last_value(:uncontrolled_patients_rate), precision: 0) %>
@@ -139,7 +139,7 @@
-
+
-
+
@@ -166,7 +166,7 @@
Total number of HTN patient registrations
-
+
<% if @data.last_value(:cumulative_registrations).zero? %>
No data
@@ -193,7 +193,7 @@
<% else %>
-
+
<% end %>
diff --git a/config/environments/production.rb b/config/environments/production.rb
index fcd4982330..e4ff4e23eb 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -105,7 +105,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
- logger = ActiveSupport::Logger.new(STDOUT)
+ logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
diff --git a/config/initializers/time_and_date_formats.rb b/config/initializers/time_and_date_formats.rb
index 521ce88448..4003217651 100644
--- a/config/initializers/time_and_date_formats.rb
+++ b/config/initializers/time_and_date_formats.rb
@@ -1,5 +1,5 @@
-Time::DATE_FORMATS[:mon_year] = "%b %Y"
-Date::DATE_FORMATS[:mon_year] = "%b %Y"
+Time::DATE_FORMATS[:mon_year] = "%b-%Y"
+Date::DATE_FORMATS[:mon_year] = "%b-%Y"
Time::DATE_FORMATS[:month_year] = "%B %Y"
Date::DATE_FORMATS[:month_year] = "%B %Y"
diff --git a/config/puma.rb b/config/puma.rb
index 33f5fae7ab..3a4feda19a 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -4,12 +4,12 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
-threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
-port ENV.fetch("PORT") { 3000 }
+port ENV.fetch("PORT", 3000)
# Specifies the `environment` that Puma will run in.
#
diff --git a/lib/loggers/api_usage_logger.rb b/lib/loggers/api_usage_logger.rb
index a7860c9164..262b27e6ec 100644
--- a/lib/loggers/api_usage_logger.rb
+++ b/lib/loggers/api_usage_logger.rb
@@ -13,7 +13,7 @@ class Formatter < ActiveSupport::Logger::Formatter
include ActiveSupport::TaggedLogging::Formatter
end
- def initialize(target = STDOUT)
+ def initialize(target = $stdout)
super(target)
self.formatter = Formatter.new
end
diff --git a/lib/tasks/dell_demo.rake b/lib/tasks/dell_demo.rake
index 47b6c1a6e8..98ab08680d 100644
--- a/lib/tasks/dell_demo.rake
+++ b/lib/tasks/dell_demo.rake
@@ -10,7 +10,7 @@ namespace :dell_demo do
#
# Only print on console
#
- logger = Logger.new(STDOUT)
+ logger = Logger.new($stdout)
#
# Parse args
diff --git a/spec/models/period_spec.rb b/spec/models/period_spec.rb
index 4a1893cb7a..132d620797 100644
--- a/spec/models/period_spec.rb
+++ b/spec/models/period_spec.rb
@@ -20,7 +20,7 @@
expect(jan_1_2019.to_period.value).to eq(Date.parse("January 1st 2019").to_period.value)
end
- it "validations" do
+ it "has validations" do
period = Period.new(type: "invalid", value: jan_1_2020)
expect(period).to be_invalid
expect(period.errors[:type]).to eq(["must be month or quarter"])
@@ -28,6 +28,11 @@
expect(period).to be_valid
end
+ it "has to_s in correct format" do
+ expect(jan_1_2019_month_period.to_s).to eq("Jan-2019")
+ expect(q1_2019_period.to_s).to eq("Q1-2019")
+ end
+
it "period months can be compared" do
expect(jan_1_2020_month_period).to be > jan_1_2019_month_period
expect(jan_1_2019_month_period).to be < jan_1_2020_month_period
diff --git a/spec/services/region_report_service_spec.rb b/spec/services/region_report_service_spec.rb
index 07a7305605..03302900a9 100644
--- a/spec/services/region_report_service_spec.rb
+++ b/spec/services/region_report_service_spec.rb
@@ -138,14 +138,14 @@ def refresh_views
result = service.call
expected_controlled_patients = {
- "Jul 2018" => 2, "Aug 2018" => 2, "Sep 2018" => 2,
- "Feb 2020" => 2, "Mar 2020" => 2, "Apr 2020" => 4, "May 2020" => 2, "Jun 2020" => 2
+ "Jul-2018" => 2, "Aug-2018" => 2, "Sep-2018" => 2,
+ "Feb-2020" => 2, "Mar-2020" => 2, "Apr-2020" => 4, "May-2020" => 2, "Jun-2020" => 2
}
expected_controlled_patients.default = 0
expected_cumulative_registrations = {
- "Oct 2019" => 4, "Nov 2019" => 4, "Dec 2019" => 6,
- "Jan 2020" => 6, "Feb 2020" => 6, "Mar 2020" => 6, "Apr 2020" => 6, "May 2020" => 6, "Jun 2020" => 6
+ "Oct-2019" => 4, "Nov-2019" => 4, "Dec-2019" => 6,
+ "Jan-2020" => 6, "Feb-2020" => 6, "Mar-2020" => 6, "Apr-2020" => 6, "May-2020" => 6, "Jun-2020" => 6
}
# NOTE: we set the default for the values that are excluded in the hash, otherwise we'd have to enumerate all 24
# months of data in the hash