mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 01:06:22 +00:00
45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
# 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?
|
|
build_stats.jekyll.where(status: true).count > 1
|
|
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
|