Skip to content

Conversation

@hendrikb
Copy link
Collaborator

Check this out: Run the migration to add the new people_in_household field to the User model. Then head over to the graphs page and learn about this month's waste with an overview about how your household is doing and how it's going per-person.

The statistics are not super beautified, but as a feature I call it MVP. ;)

@hendrikb hendrikb requested a review from Garllon April 28, 2021 21:28
class AddPeopleInHouseholdToUsers < ActiveRecord::Migration[6.1]
def change
add_column :users, :people_in_household, :integer, default: 1
User.all.each do |user|
Copy link
Owner

Choose a reason for hiding this comment

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

Normally this is not a good practise and i would think this will also fail, when you run rollback.

%th Source
%tbody
- GraphPresenter::GARBAGE.each do |key, value|
- household_weight = Pile.where(user_id: current_user.id).where(kind: key).group("DATE_TRUNC('month', produced_at)").sum(:weight).values.first
Copy link
Owner

Choose a reason for hiding this comment

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

This should go to a presenter, but anywise my plan was also to refactor the whole logic, so maybe currently i see this as a optimization.

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