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
include GAppsProvisioning | |
class Account < PapertrailDist | |
before_validation :set_default_values | |
after_save :redis_account_update | |
before_destroy :redis_account_delete | |
has_many :routers | |
has_many :clients, :through => :users, :uniq => true |
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
quantity |
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
quantity |
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
$ -> | |
subscription.hijackMinusBtn() | |
subscription.hijackPlusBtn() | |
subscription = | |
hijackMinusBtn: -> | |
$('.minus_quantity').click (event) -> | |
current_quantity = subscription.getQuantity() | |
$('#quantity').val(if current_quantity < 2 then 1 else current_quantity - 1) | |
subscription.updateViewElements(event.currentTarget) |
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
def twoway_guest_pw | |
return self.gibberish_guest_pw unless self.gibberish_guest_pw.blank? | |
self.gpg_guest_pw | |
end |
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
context 'crunch stupid simple data' do | |
let(:start_time) { DateTime.now - 5.days } | |
let(:crunched) { [30, 10, 10, 0, 0] } | |
before do | |
FactoryGirl.create(:data_usage, recorded_at: start_time, bytes_in: 5, bytes_out: 5, net_interface: interface) | |
FactoryGirl.create(:data_usage, recorded_at: start_time + 2.hours, bytes_in: 5, bytes_out: 5, net_interface: interface) | |
FactoryGirl.create(:data_usage, recorded_at: start_time + 4.hours, bytes_in: 5, bytes_out: 5, net_interface: interface) | |
FactoryGirl.create(:data_usage, recorded_at: start_time + 2.days, bytes_in: 5, bytes_out: 5, net_interface: interface) | |
FactoryGirl.create(:data_usage, recorded_at: start_time + 2.days, bytes_in: 5, bytes_out: 5, net_interface: interface) |
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
class MakeNormalizedNetInterfaceDataUsagesPolymorphic < ActiveRecord::Migration | |
def up | |
rename_column :normalized_net_interface_data_usages, :net_interface_id, :measurable_data_id | |
add_column :normalized_net_interface_data_usages, :measurable_data_type, :string | |
change_table :net_interfaces do |t| | |
t.references :measurable_data, polymorphic: true | |
end | |
change_table :router_configs do |t| |
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
class AbstractNotificationRules < ActiveRecord::Migration | |
def up | |
rename_table :notification_rules, :activity_notification_rules | |
create_table :data_usage_notification_rules do |t| | |
t.string :email | |
t.integer :phone | |
t.integer :data_total | |
t.integer :account_id |
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
def self.get_data_usage(thing) | |
bytes_in = thing.get_data_usage(method_name: :bytes_in) | |
bytes_out = thing.get_data_usage(method_name: :bytes_out) | |
total_bytes = thing.get_data_usage | |
return if total_bytes.nil? | |
zeros = 0 | |
total_bytes.each do |u| | |
break if u > 0 |
OlderNewer