From bbafcfa40f4aacaccb58eb0bc72676622b6c810e Mon Sep 17 00:00:00 2001 From: Hugo Peixoto Date: Fri, 28 Jul 2023 12:00:41 +0100 Subject: [PATCH] Humanizes bytesizes --- .dockerignore | 1 + .gitignore | 1 + Dockerfile | 4 ++++ index.html.erb | 4 ++-- main.rb | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3c09199..32222b5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ /videos/ /videos.db +/public/ /.gitignore diff --git a/.gitignore b/.gitignore index 8386a83..3ccec54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /videos/ /videos.db +/public/ diff --git a/Dockerfile b/Dockerfile index a434427..e0dd02c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,11 @@ RUN bundle ADD config.ru ./ ADD *.rb ./ ADD index.html.erb ./ + +WORKDIR /app/public ADD saca-sapos ./ +RUN tar czf saca-sapos.tar.gz saca-sapos +WORKDIR /app EXPOSE 4567 CMD ["puma", "-p", "4567"] diff --git a/index.html.erb b/index.html.erb index 02b5b89..1757551 100644 --- a/index.html.erb +++ b/index.html.erb @@ -42,8 +42,8 @@ $ PROCS=10 /caminho/para/o/saca-sapos 1000 eu@exemplo.pt

Estatísticas

Número de vídeos descarregados: <%= stats[:downloads]["total"].to_i %>

-

Tamanho total: <%= stats[:downloads]["bytes"].to_i / 1024 / 1024 %> MiB

-

Tamanho médio: <%= stats[:downloads]["bytes"].to_i / 1024 / 1024 / stats[:downloads]["total"].to_i %> MiB/vídeo

+

Tamanho total: <%= h(stats[:downloads]["bytes"].to_i) %>

+

Tamanho médio: <%= h(stats[:downloads]["bytes"].to_i / stats[:downloads]["total"].to_i) %>/vídeo