2023-03-31 22:32:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Site
|
|
|
|
module BuildStats
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
# Devuelve el tiempo promedio de publicación para este sitio
|
|
|
|
#
|
|
|
|
# @return [Integer]
|
|
|
|
def average_publication_time
|
|
|
|
build_stats.group(:action).average(:seconds).values.reduce(:+).round
|
|
|
|
end
|
|
|
|
|
|
|
|
# Devuelve el tiempo promedio de compilación para sitios similares
|
|
|
|
# a este.
|
|
|
|
#
|
|
|
|
# @return [Integer]
|
|
|
|
def average_publication_time_for_similar_sites
|
|
|
|
similar_deploys = Deploy.where(type: deploys.pluck(:type)).pluck(:id)
|
|
|
|
|
|
|
|
BuildStat.where(deploy_id: similar_deploys).group(:action).average(:seconds).values.reduce(:+).round
|
|
|
|
end
|
|
|
|
|
|
|
|
# Define si podemos calcular el tiempo promedio de publicación
|
|
|
|
# para este sitio
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
def average_publication_time_calculable?
|
2023-03-31 23:51:20 +00:00
|
|
|
build_stats.jekyll.where(status: true).count > 1
|
2023-03-31 22:32:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def similar_sites?
|
|
|
|
!design.no_theme?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Detecta si el sitio todavía no ha sido publicado
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
def not_published_yet?
|
|
|
|
build_stats.jekyll.where(status: true).count.zero?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|