bundle exec rake algolia:reindex
crashes because there is no tag.topic_count
any more since this commit.
Clearing users from Algolia
Pushing users to Algolia
..
Successfully pushed 530 users to Algolia
Clearing tags from Algolia
Pushing tags to Algolia
rake aborted!
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
Manually changing it to staff_topic_count fixes stuff but maybe there are side effects to this?
--- 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