From 61b3b973134720cee2f024895829d072a52f6458 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 7 Aug 2021 19:57:49 -0300 Subject: [PATCH] Obtener los AccessLog para cada Site MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A través del hostname, ¡magia! Esto nos habilita a obtener estadísticas más adelante... --- app/models/deploy.rb | 2 ++ app/models/site.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/models/deploy.rb b/app/models/deploy.rb index 0da07be..37790eb 100644 --- a/app/models/deploy.rb +++ b/app/models/deploy.rb @@ -9,6 +9,8 @@ require 'open3' class Deploy < ApplicationRecord # Un sitio puede tener muchas formas de publicarse. belongs_to :site + # Puede tener muchos access logs a través del hostname + has_many :access_logs, primary_key: 'hostname', foreign_key: 'host' # Siempre generar el hostname after_initialize :default_hostname! diff --git a/app/models/site.rb b/app/models/site.rb index c935765..d0c420f 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -39,6 +39,7 @@ class Site < ApplicationRecord has_many :log_entries, dependent: :destroy has_many :deploys, dependent: :destroy + has_many :access_logs, through: :deploys has_many :build_stats, through: :deploys has_many :roles, dependent: :destroy has_many :usuaries, -> { where('roles.rol = ?', 'usuarie') },