2021-05-17 18:33:46 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Site
|
2023-09-27 18:40:14 +00:00
|
|
|
# Indexa todos los artículos de un sitio
|
|
|
|
#
|
|
|
|
# TODO: Hacer opcional
|
2021-05-17 18:33:46 +00:00
|
|
|
module Index
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
# TODO: Debería ser un Job?
|
|
|
|
after_create :index_posts!
|
|
|
|
has_many :indexed_posts, dependent: :destroy
|
|
|
|
|
|
|
|
def index_posts!
|
|
|
|
Site.transaction do
|
2022-08-03 16:11:06 +00:00
|
|
|
docs.each(&:index!)
|
2023-09-27 18:40:14 +00:00
|
|
|
|
|
|
|
update(last_indexed_commit: repository.head_commit.oid)
|
2021-05-17 18:33:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|