mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 14:21:41 +00:00
poder indexar los sitios!
me había olvidado de este archivo
This commit is contained in:
parent
7b15a32de0
commit
df425bab5a
1 changed files with 24 additions and 0 deletions
24
app/models/site/index.rb
Normal file
24
app/models/site/index.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Indexa todos los artículos de un sitio
|
||||
#
|
||||
# TODO: Hacer opcional
|
||||
class Site
|
||||
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
|
||||
docs.each do |post|
|
||||
post.to_index.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue