Add bytes and count per contact
This commit is contained in:
parent
fc7eb83800
commit
aa8a920288
@ -88,6 +88,13 @@ $ PROCS=10 /caminho/para/o/saca-sapos download 1000 eu@exemplo.pt
|
|||||||
<p>Tamanho total estimado: <%= h bytes_downloaded / videos_downloaded * videos_known %></p>
|
<p>Tamanho total estimado: <%= h bytes_downloaded / videos_downloaded * videos_known %></p>
|
||||||
<p>Número de pessoas a descarregar vídeos: <%= users %></p>
|
<p>Número de pessoas a descarregar vídeos: <%= users %></p>
|
||||||
|
|
||||||
|
<p>Tamanho descarregado por cada pessoa:</p>
|
||||||
|
<ol>
|
||||||
|
<% downloads_per_user.each_with_index do |downloads, index| %>
|
||||||
|
<li><%= h downloads["size"] %> (<%= downloads["total"] %> vídeos)</li>
|
||||||
|
<% end %>
|
||||||
|
</ol>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
3
main.rb
3
main.rb
@ -31,6 +31,7 @@ get '/' do
|
|||||||
|
|
||||||
videos = ActiveRecord::Base.connection.execute("select count(1) AS total from videos;")[0]
|
videos = ActiveRecord::Base.connection.execute("select count(1) AS total from videos;")[0]
|
||||||
users = ActiveRecord::Base.connection.execute("select count(distinct email) AS total from downloads;")[0]
|
users = ActiveRecord::Base.connection.execute("select count(distinct email) AS total from downloads;")[0]
|
||||||
|
downloads_per_user = ActiveRecord::Base.connection.execute("select SUM(size) AS size, COUNT(1) AS total FROM (select email, video_id, MAX(size) as size from downloads group by email, video_id) x GROUP BY email ORDER BY 1 DESC;")
|
||||||
|
|
||||||
stats = {
|
stats = {
|
||||||
videos_known: videos["total"].to_i,
|
videos_known: videos["total"].to_i,
|
||||||
@ -38,6 +39,8 @@ get '/' do
|
|||||||
|
|
||||||
bytes_downloaded: downloads["bytes"].to_i,
|
bytes_downloaded: downloads["bytes"].to_i,
|
||||||
|
|
||||||
|
downloads_per_user: downloads_per_user,
|
||||||
|
|
||||||
users: users["total"],
|
users: users["total"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user