fastruby/pecas

View on GitHub
app/models/concerns/calculation.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'active_support/concern'

module Calculation
  extend ActiveSupport::Concern

  def minutes_of_week(weeks_ago)
    start_date = (Time.now.beginning_of_week - weeks_ago.week).to_date
    end_date = (Time.now.end_of_week - weeks_ago.week).to_date
    entries.where(date: start_date..end_date).sum(:minutes)
  end
end