Obtener los AccessLog para cada Site
A través del hostname, ¡magia! Esto nos habilita a obtener estadísticas más adelante...
This commit is contained in:
parent
e14e53c2a1
commit
61b3b97313
2 changed files with 3 additions and 0 deletions
|
@ -9,6 +9,8 @@ require 'open3'
|
||||||
class Deploy < ApplicationRecord
|
class Deploy < ApplicationRecord
|
||||||
# Un sitio puede tener muchas formas de publicarse.
|
# Un sitio puede tener muchas formas de publicarse.
|
||||||
belongs_to :site
|
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
|
# Siempre generar el hostname
|
||||||
after_initialize :default_hostname!
|
after_initialize :default_hostname!
|
||||||
|
|
|
@ -39,6 +39,7 @@ class Site < ApplicationRecord
|
||||||
|
|
||||||
has_many :log_entries, dependent: :destroy
|
has_many :log_entries, dependent: :destroy
|
||||||
has_many :deploys, dependent: :destroy
|
has_many :deploys, dependent: :destroy
|
||||||
|
has_many :access_logs, through: :deploys
|
||||||
has_many :build_stats, through: :deploys
|
has_many :build_stats, through: :deploys
|
||||||
has_many :roles, dependent: :destroy
|
has_many :roles, dependent: :destroy
|
||||||
has_many :usuaries, -> { where('roles.rol = ?', 'usuarie') },
|
has_many :usuaries, -> { where('roles.rol = ?', 'usuarie') },
|
||||||
|
|
Loading…
Reference in a new issue