end
CALL_TYPES = {
- :map => "Map API calls",
- :upload => "Changeset diff uploads",
- :amf => "AMF API calls",
- :history => "Element history fetches",
+ :map => "Map API calls",
+ :upload => "Changeset diff uploads",
+ :amf => "AMF API calls",
+ :history => "Element history fetches",
:full => "Full element fetches",
:trkpts => "GPX trackpoints calls",
- :web => "Web site traffic",
+ :web => "Web site traffic",
:other => "Other API calls"
}
def categorise_uri(line)
uri = line.split(" ")[1]
-
+
case uri
when /api\/0\.6\/map/ then :map
when /api\/0\.6\/changeset\/[0-9]*\/upload/ then :upload
min_time, max_time, lines = uris_from_logs
delta_t = (max_time - min_time).to_f * 24 * 60
counts = lines.
- collect {|x| categorise_uri(x)}.
+ collect { |x| categorise_uri(x) }.
inject(Hash.new) do |h, e|
if h.has_key? e
h[e] += 1
end
h
end
-
+
CALL_TYPES.keys.each do |type|
count = counts[type] || 0
puts "#{type}.value #{count / delta_t}"