diff options
author | ThibG <thib@sitedethib.com> | 2018-11-09 22:29:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 22:29:52 +0100 |
commit | 09562b0fcc193d66f89a9f2c7eb2684e2e554d83 (patch) | |
tree | 87747f5dda99de033d15ec1319a7c188fa0df750 /app/services/hashtag_query_service.rb | |
parent | 868cace7975532509c41800c7b6b9a6c7838a6b0 (diff) | |
parent | c6fc3e0c65a0ae78e76ebb5da1a12a23727b72c8 (diff) |
Merge pull request #806 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/services/hashtag_query_service.rb')
-rw-r--r-- | app/services/hashtag_query_service.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/services/hashtag_query_service.rb b/app/services/hashtag_query_service.rb new file mode 100644 index 000000000..86558a446 --- /dev/null +++ b/app/services/hashtag_query_service.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class HashtagQueryService < BaseService + def call(tag, params, account = nil, local = false) + any = tags_for(params[:any]) + 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 + end + + private + + def tags_for(tags) + Tag.where(name: tags.map(&:downcase)) if tags.presence + end +end |