Skip to content

Commit

Permalink
More accurate pivotal results
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Vartanov committed Dec 31, 2009
1 parent cbd3edc commit 7e0a495
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/traffic.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def local_address
@local_address ||= find_local_address @local_address ||= find_local_address
end end


def highest_five_hosts def highest_twenty_hosts
highest_hosts(5) highest_hosts(20)
end end


def hosts def hosts
Expand All @@ -20,7 +20,7 @@ def hosts


def highest_hosts(limit=0) def highest_hosts(limit=0)
sorted_hosts = hosts.sort { |left, right| right.amount_of_traffic <=> left.amount_of_traffic } sorted_hosts = hosts.sort { |left, right| right.amount_of_traffic <=> left.amount_of_traffic }
limit.nil? ? sorted_hosts : sorted_hosts[0..limit-1] sorted_hosts[0..limit-1]
end end


def grouped_by_host def grouped_by_host
Expand Down
12 changes: 7 additions & 5 deletions lib/traffic_splitter.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,12 @@
class TrafficSplitter class TrafficSplitter
def self.split_traffic!(traffic) def self.split_traffic!(traffic)
hosts = traffic.daily.internal.highest_five_hosts + hosts = traffic.daily.internal.highest_twenty_hosts +
traffic.nightly.internal.highest_five_hosts + traffic.nightly.internal.highest_twenty_hosts +
traffic.daily.world.highest_five_hosts + traffic.daily.world.highest_twenty_hosts +
traffic.nightly.world.highest_five_hosts traffic.nightly.world.highest_twenty_hosts


hosts.sort { |left, right| right.amount_of_traffic <=> left.amount_of_traffic } hosts.sort! { |left, right| right.amount_of_traffic <=> left.amount_of_traffic }

hosts[0..19]
end end
end end

0 comments on commit 7e0a495

Please sign in to comment.