Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer Cohort Report Download Links #931

Merged
merged 5 commits into from May 6, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/analytics/districts_controller.rb
Expand Up @@ -95,6 +95,9 @@ def analytics_cache_key
end

def download_filename
"district-cohort-report_#{@organization_district.district_name}_#{Time.current.to_s(:number)}.csv"
period = @period == :quarter ? "quarterly" : "monthly"
district = @organization_district.district_name
time = Time.current.to_s(:number)
"district-#{period}-cohort-report_#{district}_#{time}.csv"
end
end
5 changes: 4 additions & 1 deletion app/controllers/analytics/facilities_controller.rb
Expand Up @@ -88,6 +88,9 @@ def analytics_cache_key
end

def download_filename
"facility-cohort-report_#{@facility.name}_#{Time.current.to_s(:number)}.csv"
period = @period == :quarter ? "quarterly" : "monthly"
facility = @facility.name
time = Time.current.to_s(:number)
"facility-#{period}-cohort-report_#{facility}_#{time}.csv"
end
end
9 changes: 5 additions & 4 deletions app/views/analytics/districts/show.csv.erb
@@ -1,17 +1,18 @@
<%= [
"Report generated at:",
'Report generated at:',
Time.current
].to_csv -%>
<%= ["#{@organization_district.district_name} Cohort Report"].to_csv -%>
<% period = @period == :quarter ? 'Quarterly' : 'Monthly' %>
<%= ["#{@organization_district.district_name} #{period} Cohort Report"].to_csv -%>
<%= ['Facility'].concat(@cohort_analytics.each_with_index.flat_map do |(report_dates, analytics), index|
[
'Cohort period',
'Follow up period',
'Patients registered',
'Patients in cohort',
'Patients followed up',
'Patients controlled',
'Patients uncontrolled',
'Patients defaulted',
"Patients didn't attend",
'Control rate',
'Uncontrolled rate',
'Default rate',
Expand Down
12 changes: 9 additions & 3 deletions app/views/analytics/districts/show.html.erb
Expand Up @@ -23,9 +23,15 @@
<h4>Downloads</h4>

<p>
<%= link_to(period: params[:period], format: :csv) do %>
<i class="far fa-file-excel mr-2"></i>
Cohort report
<%= link_to(period: :quarter, format: :csv) do %>
<i class="far fa-file-excel mr-2"></i>
Quarterly cohort report
<% end %>
</p>
<p>
<%= link_to(period: :month, format: :csv) do %>
<i class="far fa-file-excel mr-2"></i>
Monthly cohort report
<% end %>
</p>

Expand Down
25 changes: 13 additions & 12 deletions app/views/analytics/facilities/show.csv.erb
@@ -1,19 +1,20 @@
<%= [
"Report generated at:",
'Report generated at:',
Time.current
].to_csv -%>
<%= ["#{@facility.name} Cohort Report"].to_csv -%>
<% period = @period == :quarter ? 'Quarterly' : 'Monthly' %>
<%= ["#{@facility.name} #{period} Cohort Report"].to_csv -%>
<%= [
"Cohort period",
"Follow up period",
"Patients registered",
"Patients followed up",
"Patients controlled",
"Patients uncontrolled",
"Patients defaulted",
"Control rate",
"Uncontrolled rate",
"Default rate"
'Cohort period',
'Follow up period',
'Patients in cohort',
'Patients followed up',
'Patients controlled',
'Patients uncontrolled',
"Patients didn't attend",
'Control rate',
'Uncontrolled rate',
'Default rate'
].to_csv -%>
<% @cohort_analytics.each_with_index do |(report_dates, analytics), index| %>
<%
Expand Down
12 changes: 9 additions & 3 deletions app/views/analytics/facilities/show.html.erb
Expand Up @@ -34,9 +34,15 @@
<h4>Downloads</h4>

<p>
<%= link_to(period: params[:period], format: :csv) do %>
<i class="far fa-file-excel mr-2"></i>
Cohort report
<%= link_to(period: :quarter, format: :csv) do %>
<i class="far fa-file-excel mr-2"></i>
Quarterly cohort report
<% end %>
</p>
<p>
<%= link_to(period: :month, format: :csv) do %>
<i class="far fa-file-excel mr-2"></i>
Monthly cohort report
<% end %>
</p>

Expand Down