]> cat aescling's git repositories - mastodon.git/commitdiff
Simplify hashtag query service, perf increase for 'any' tags (#9298)
authorJames Kiesel <james.kiesel@gmail.com>
Mon, 19 Nov 2018 11:49:50 +0000 (00:49 +1300)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 19 Nov 2018 11:49:50 +0000 (12:49 +0100)
app/services/hashtag_query_service.rb

index 86558a44623fd794cfed7b6ed344a4072fe5078f..5773d78c6e2d2a38275558dce58b59878d59b001 100644 (file)
@@ -2,15 +2,14 @@
 
 class HashtagQueryService < BaseService
   def call(tag, params, account = nil, local = false)
-    any  = tags_for(params[:any])
+    tags = tags_for(Array(tag.name) | Array(params[:any])).pluck(:id)
     all  = tags_for(params[:all])
     none = tags_for(params[:none])
 
-    @query = Status.as_tag_timeline(tag, account, local)
-                   .tagged_with_all(all)
-                   .tagged_with_none(none)
-    @query = @query.distinct.or(self.class.new.call(any, params.except(:any), account, local).distinct) if any
-    @query
+    Status.distinct
+          .as_tag_timeline(tags, account, local)
+          .tagged_with_all(all)
+          .tagged_with_none(none)
   end
 
   private