-
Notifications
You must be signed in to change notification settings - Fork 112
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
LG-14259 Update Report formatting #11166
Changes from 4 commits
c997a09
200a80f
cb99a1a
6e05bd7
ba1f27f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,22 +51,30 @@ def progress? | |
end | ||
|
||
def as_emailable_reports | ||
Reporting::EmailableReport.new( | ||
Comment on lines
53
to
-54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm glad this plural method name is now actually returning an array |
||
title: 'LG-99 Metrics', | ||
table: lg99_metrics_table, | ||
filename: 'lg99_metrics', | ||
) | ||
[ | ||
Reporting::EmailableReport.new( | ||
title: "Monthly LG-99 Metrics #{stats_month}", | ||
table: lg99_metrics_table, | ||
filename: 'lg99_metrics', | ||
), | ||
Reporting::EmailableReport.new( | ||
title: "Monthly Suspended User Metrics #{stats_month}", | ||
table: suspended_metrics_table, | ||
filename: 'suspended_metrics', | ||
), | ||
Reporting::EmailableReport.new( | ||
title: "Monthly Reinstated User Metrics #{stats_month}", | ||
table: reinstated_metrics_table, | ||
filename: 'reinstated_metrics', | ||
), | ||
] | ||
end | ||
|
||
def lg99_metrics_table | ||
[ | ||
['Metric', 'Total'], | ||
['Unique users seeing LG-99', lg99_unique_users_count.to_s], | ||
['Unique users suspended', unique_suspended_users_count.to_s], | ||
['Average Days Creation to Suspension', user_days_to_suspension_avg.to_s], | ||
['Average Days Proofed to Suspension', user_days_proofed_to_suspension_avg.to_s], | ||
['Unique users reinstated', unique_reinstated_users_count.to_s], | ||
['Average Days to Reinstatement', user_days_to_reinstatement_avg.to_s], | ||
['Metric', 'Total', 'Range Start', 'Range End'], | ||
['Unique users seeing LG-99', lg99_unique_users_count.to_s, time_range.begin.to_s, | ||
time_range.end.to_s], | ||
] | ||
rescue Aws::CloudWatchLogs::Errors::ThrottlingException => err | ||
[ | ||
|
@@ -75,14 +83,70 @@ def lg99_metrics_table | |
] | ||
end | ||
|
||
def to_csv | ||
CSV.generate do |csv| | ||
lg99_metrics_table.each do |row| | ||
csv << row | ||
def suspended_metrics_table | ||
[ | ||
['Metric', 'Total', 'Range Start', 'Range End'], | ||
[ | ||
'Unique users suspended', | ||
unique_suspended_users_count.to_s, | ||
time_range.begin.to_s, | ||
time_range.end.to_s, | ||
], | ||
[ | ||
'Average Days Creation to Suspension', | ||
user_days_to_suspension_avg.to_s, | ||
time_range.begin.to_s, | ||
time_range.end.to_s, | ||
], | ||
[ | ||
'Average Days Proofed to Suspension', | ||
user_days_proofed_to_suspension_avg.to_s, | ||
time_range.begin.to_s, | ||
time_range.end.to_s, | ||
], | ||
] | ||
end | ||
|
||
def reinstated_metrics_table | ||
[ | ||
['Metric', 'Total', 'Range Start', 'Range End'], | ||
[ | ||
'Unique users reinstated', | ||
unique_reinstated_users_count.to_s, | ||
time_range.begin.to_s, | ||
time_range.end.to_s, | ||
], | ||
[ | ||
'Average Days to Reinstatement', | ||
user_days_to_reinstatement_avg.to_s, | ||
time_range.begin.to_s, | ||
time_range.end.to_s, | ||
], | ||
] | ||
end | ||
|
||
def as_tables | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto, this is unused too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, done. If we ever want to mimic some of the other reporting then we can just add it back. |
||
[ | ||
lg99_metrics_table, | ||
suspended_metrics_table, | ||
reinstated_metrics_table, | ||
] | ||
end | ||
|
||
def to_csvs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method is unused now, right? let's remove it entirely |
||
as_tables.map do |table| | ||
CSV.generate do |csv| | ||
table.each do |row| | ||
csv << row | ||
end | ||
end | ||
end | ||
end | ||
|
||
def stats_month | ||
time_range.begin.strftime('%b-%Y') | ||
end | ||
|
||
# event name => set(user ids) | ||
# @return Hash<String,Set<String>> | ||
def data | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the accessor.