rubyforgood / rubyforgood/human-essentials

Refactor report controller/views to remove local calculations

Open
#4,136 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

refactor stale
Dominant language
Ruby
Stars
593
Forks
593
Avg merge
4d 22h
Merged PRs (30d)
41

Description

Summary

Inspired by View::Inventory, let's refactor report controller/views to incorporate all the queries into a single object (or set of objects) that can be passed down in the view. Look for any calculation, including things like sum and count in the view... We much prefer views to be extremely dumb and doing nothing but passing existing data into (possibly) rendering functions like number_to_delimiter.

Having a view object which we can calculate allows us a) to not have to deal with five or more instance variables and just have one, and b) to centralize all the logic that calculates that one view object.

Things to consider

No response

Criteria for Completion
  • Reports controller/views should have minimal calculations
  • Unit tests on calculations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the report controller and views, then compare their structure with View::Inventory. Identify calculations such as sums and counts that belong in a shared view object or objects, add unit tests for those calculations, and verify that the reports controller and views perform minimal calculations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
analytics, backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.