Created
January 16, 2014 12:43
-
-
Save antulik/8454423 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class ProfilesController < ApplicationController | |
def index | |
@tracking_profiles = current_user.tracking_profiles | |
end | |
end |
This file contains hidden or 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
module TrackingProfileDecorator | |
def filtered_hourly_stats | |
hourly_stats = self.hourly_stats.select do |s| | |
date_range.begin < s.time && s.time < date_range.end | |
end | |
self.attributes. | |
merge(self.profile.attributes). | |
merge('stats' => Stat.merge(hourly_stats)). | |
merge('hourly_stats' => hourly_stats) | |
end | |
end |
This file contains hidden or 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
- for profile in @tracking_profiles | |
= render 'profile', profile: profile.filtered_hourly_stats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment