-
-
Save Jeiwan/947de8cfe333759b42cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
module Stats | |
class << self | |
def calculate_stats(model, date_from = Date.today - 7, date_to = Date.today) | |
process_tracks(date_from, date_to).map do |track| | |
# Bar.get_stats_hash(track) | |
track | |
end | |
end | |
private | |
def process_tracks(date_from, date_to) | |
# tracks = Track.all | |
# (...) | |
%w(some useful and important stats) | |
end | |
end | |
end | |
# Stats.calculate_stats(Campaign, params[:date_from], params[:date_to]) | |
class StatsClass | |
def initialize(model, date_from = Date.today - 7, date_to = Date.today) | |
@model = model | |
@date_from = date_from | |
@date_to = date_to | |
end | |
def calculate_stats | |
@stats ||= process_tracks.map do |track| | |
# Bar.get_stats_hash(track) | |
track | |
end | |
end | |
private | |
def process_tracks | |
# tracks = Track.all | |
# (...) | |
%w(some useful and important stats) | |
end | |
end | |
# StatsClass.new(Campaign, parmas[:date_from], params[:date_to]).calculate_stats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment