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
mark@stats:~/$ ruby test.rb | |
document : 300.0 | |
image : 17910.0 | |
video : 1000.0 |
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 pie(data_array) | |
@labels = "" | |
@data_str = "" | |
@data = [] | |
@sum = 0 | |
data_array.find().to_a.each do |f| | |
@labels += "#{f['_id']}|" | |
@sum += f['value']['count'].to_i | |
@data.push(f['value']['count'].to_i) | |
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
%h1 | |
Stats | |
#upload | |
Uploaded File Breakdown | |
#pie= @upload_types |
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
require 'rubygems' | |
require 'sinatra' | |
require 'haml' | |
require 'model' | |
set :port, 80 | |
get '/' do | |
protected! |
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
{"video", [{count: 1}, {count: 1}, {count: 1}, {count: 1}]} |
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
function() { | |
emit(this.time - (this.time % 86400), {count: 1}); | |
} |
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
require 'rubygems' | |
require 'mongo' | |
def db | |
$db ||= Mongo::Connection.new("localhost", 27017).db("logs") | |
end | |
def logs | |
$logs ||= db.collection("flex") | |
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
require 'model' | |
require 'time' | |
@s = Chart.count_all_activity | |
@s.find().to_a.each do |f| | |
puts "#{f['_id']} (#{Time.at(f['_id'])}) : #{f['value']['count']}" | |
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
mark@stats:~/$ ruby test.rb | |
...more results... | |
1260835200.0 (Tue Dec 15 00:00:00 +0000 2009) : 316.0 | |
1260921600.0 (Wed Dec 16 00:00:00 +0000 2009) : 1874.0 | |
1261008000.0 (Thu Dec 17 00:00:00 +0000 2009) : 516.0 | |
1261094400.0 (Fri Dec 18 00:00:00 +0000 2009) : 642.0 | |
...more results... | |
mark@stats:~/$ |
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
%html | |
%head | |
%title Stats Server | |
%meta{"http-equive" => "Content-Type", :content=>"text/html; charset=utf-8"}/ | |
<script type="text/javascript" src="/flot/jquery.js"></script> | |
<script language="javascript" type="text/javascript" src="/flot/jquery.flot.js"></script> | |
<script language="javascript" type="text/javascript" src="/flot/jquery.flot.selection.js"></script> | |
%body | |
=yield |