bundle exec rake algolia:reindex falha porque não há mais tag.topic_count desde o commit aqui.
Limpando usuários do Algolia
Enviando usuários para o Algolia
..
Usuários enviados com sucesso para o Algolia: 530
Limpando tags do Algolia
Enviando tags para o Algolia
rake abortado!
NoMethodError: undefined method `topic_count' for #<Tag id: 1, name: "installation", created_at: "2021-12-09 11:10:14.145911000 +0000", updated_at: "2021-12-09 11:10:14.145911000 +0000", pm_topic_count: 0, target_tag_id: nil, description: nil, public_topic_count: 3, staff_topic_count: 3>
Did you mean? pm_topic_count
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4.1/lib/active_model/attribute_methods.rb:458:in `method_missing'
/var/www/discourse/plugins/discourse-algolia/lib/discourse_algolia/tag_indexer.rb:18:in `should_index?'
/var/www/discourse/plugins/discourse-algolia/lib/discourse_algolia/indexer.rb:22:in `block in process!'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4.1/lib/active_record/relation/batches.rb:71:in `each'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4.1/lib/active_record/relation/batches.rb:71:in `block in find_each'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4.1/lib/active_record/relation/batches.rb:138:in `block in find_in_batches
Alterar manualmente para staff_topic_count resolve o problema, mas talvez haja efeitos colaterais?
--- a/lib/discourse_algolia/tag_indexer.rb
+++ b/lib/discourse_algolia/tag_indexer.rb
@@ -15,10 +15,10 @@ class DiscourseAlgolia::TagIndexer < DiscourseAlgolia::Indexer
end
def should_index?(tag)
- @guardian.can_see?(tag) && tag.topic_count > 0
+ @guardian.can_see?(tag) && tag&.staff_topic_count > 0
end
def to_object(tag)
- { objectID: tag.id, url: tag.url, name: tag.name, topic_count: tag.topic_count }
+ { objectID: tag.id, url: tag.url, name: tag.name, topic_count: tag.staff_topic_count }
end
end