Last active
August 29, 2015 14:02
-
-
Save travisdmathis/0a81f8b2312a526d2d33 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
| BEGIN | |
| (0.1ms) ROLLBACK | |
| => #<MonthlyStat id: nil, client_id: 23, stat_type: "StorageTotal", month: "June", year: 2014, value: 106862824740, created_at: nil, updated_at: nil> | |
| class MonthlyStat < ActiveRecord::Base | |
| belongs_to :client | |
| attr_accessible :client_id, :month, :stat_type, :value, :year | |
| accepts_nested_attributes_for :client | |
| classy_enum_attr :stat_type, enum: 'MonthlyStatType' | |
| class << self | |
| def storage_total(client) | |
| @date = Date.today | |
| @month = @date.strftime("%B") | |
| @year = @date.strftime("%Y") | |
| @client = client | |
| @value = @client.current_storage_total | |
| puts "Date: #{@month} #{@year} - Client: #{@client} - Value: #{@value} - Client ID: #{@client.id}" | |
| MonthlyStat.create(client_id: @client.id, month: @month, value: @value, year: @year, stat_type: :StorageTotal ) | |
| end | |
| def bandwidth_usage(client) | |
| @date = Date.today | |
| @month = @date.strftime("%B") | |
| @year = @date.strftime("%Y") | |
| @client = client | |
| @value = @client.bandwidth_usage | |
| puts "Date: #{@month} #{@year} - Client: #{@client} - Value: #{@value} - Client ID: #{@client.id}" | |
| MonthlyStat.create(client_id: @client.id, month: @month, value: @value, year: @year, stat_type: :BandwidthUsage ) | |
| end | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment