Skip to content

✨ Tidy up ✨ MonthlyKeyMetricsReport#9365

Merged
n1zyy merged 7 commits intomainfrom
mattw/trying-something
Oct 12, 2023
Merged

✨ Tidy up ✨ MonthlyKeyMetricsReport#9365
n1zyy merged 7 commits intomainfrom
mattw/trying-something

Conversation

@n1zyy
Copy link
Contributor

@n1zyy n1zyy commented Oct 11, 2023

I had an idea and ran with it.

Adding new reports involves some boilerplate duplication—you need to call the report method (unavoidable), remember to upload it to S3, and then add it to the array of arrays. Since I have a story to add a new report, and there are probably about 10 more such stories in the backlog, I was feeling tired of this.

🎫 Ticket

Not requested in any ticket, but rage-coded to lay the groundwork for LG-11148.

🛠 Summary of changes

So, the idea is this:

  • Adding a new report now only requires adding it to the reports array in MonthlyKeyMetricsReport (hereinafter "MKMR").
  • For readability, I added a little Struct called Report.
  • Rather than having an array of doom arrays defining things like report title and display precision, there is a method added to the report class which contains this information.
  • By convention, the report for a given class was already foo_report, and now foo_metadata returns the metadata. I have added this to all existing reports. There is also a foo_title method which is only used in foo_metadata and need not exist, but it just feels right as a separate method.

What I wanted to do was to convention-over-configuration my way out of needing to build as much; in theory knowing there's a .account_reuse_report report method should be enough to automatically call the _metadata method as well. But I thought I was already taking on a big change here and that can be a future 🪄 trick.

Likewise, csv_name should probably also get pushed into the individual Reporting classes.

📜 Testing Plan

This passes automated tests. I am not confident that means it will generate the exact same thing. This should use a little hand-testing, and/or we should update the tests so that if some bozo introduces an "I had an idea and ran with it" PR, we can feel comfortable that the test will catch whether they broke anything.

Right now I mostly want buy-in on whether this is a great refinement or a harebrained mess.

n1zyy added 2 commits October 11, 2023 18:16
Let's make each report class responsible for its formatting
Now you should only have to update this (and the test) to add something new.
@n1zyy n1zyy requested a review from a team October 11, 2023 22:50
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, got a handful of comments

n1zyy added 2 commits October 12, 2023 16:01
[skip changelog]
^ because no one outside our team will be interested in this
table: account_deletion_report,
csv_name: 'account_deletion_rate',
)
end
Copy link
Contributor Author

@n1zyy n1zyy Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThatSpaceGuy In the event my PR lands before yours, we made some changes after you dropped from pairing, as reflected here.

We moved the Struct out into its own Reporting::EmailableReport "class", and got rid of the metadata stuff. It's all returned inline.

n1zyy and others added 3 commits October 12, 2023 16:34
@n1zyy n1zyy merged commit a59f87f into main Oct 12, 2023
@n1zyy n1zyy deleted the mattw/trying-something branch October 12, 2023 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants