From 752935afb414d864c8acfe28184b0984c021b38f Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Apr 2022 13:57:33 -0300 Subject: [PATCH] calcular bien la fecha --- Dockerfile | 2 +- app/jobs/stat_collection_job.rb | 2 +- bin/access_logs | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee6ba871..b3fd8e78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -114,7 +114,7 @@ RUN ln -s data/_private /srv/http/_private USER root # Instalar la configuración de monit RUN install -m 640 -o root -g root /srv/http/monit.conf /etc/monit.d/sutty.conf -RUN apk add --no-cache daemonize ruby-webrick +RUN apk add --no-cache daemonize ruby-webrick dateutils RUN install -m 755 /srv/http/entrypoint.sh /usr/local/bin/sutty # Mantener estos directorios! diff --git a/app/jobs/stat_collection_job.rb b/app/jobs/stat_collection_job.rb index 1ee2f2b3..a67a3c50 100644 --- a/app/jobs/stat_collection_job.rb +++ b/app/jobs/stat_collection_job.rb @@ -47,7 +47,7 @@ class StatCollectionJob < PeriodicJob def scope @scope ||= site.build_stats .jekyll - .where('created_at => ?', beginning_of_interval) + .where('created_at >= ?', beginning_of_interval) .group(:site_id) end diff --git a/bin/access_logs b/bin/access_logs index a7c151cc..cfeeb57a 100755 --- a/bin/access_logs +++ b/bin/access_logs @@ -2,9 +2,12 @@ set -e # Volcar y eliminar todos los access logs de dos días atrás -date=`bundle exec rails runner "puts (Date.today - 2.days)"` +date="`dateadd today -1d`" +file="/srv/http/_storage/${date}.psql.gz" +test -n "${date}" +test ! -f "${file}" -psql -h postgresql "${DATABASE:-sutty}" sutty < "/srv/http/_storage/${date}.psql.gz" +psql -h postgresql "${DATABASE:-sutty}" sutty < "${file}" begin; copy (select * from access_logs where created_at < '${date}') to stdout; delete from access_logs where created_at < '${date}';