This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2018-11-05 12:53:25 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class HashtagQueryService < BaseService
|
2019-10-06 21:56:21 -04:00
|
|
|
LIMIT_PER_MODE = 4
|
|
|
|
|
2018-11-05 12:53:25 -05:00
|
|
|
def call(tag, params, account = nil, local = false)
|
2018-11-19 06:49:50 -05:00
|
|
|
tags = tags_for(Array(tag.name) | Array(params[:any])).pluck(:id)
|
2018-11-05 12:53:25 -05:00
|
|
|
all = tags_for(params[:all])
|
|
|
|
none = tags_for(params[:none])
|
|
|
|
|
2018-11-19 06:49:50 -05:00
|
|
|
Status.distinct
|
|
|
|
.as_tag_timeline(tags, account, local)
|
|
|
|
.tagged_with_all(all)
|
|
|
|
.tagged_with_none(none)
|
2018-11-05 12:53:25 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-07-27 23:59:51 -04:00
|
|
|
def tags_for(names)
|
2019-10-06 21:56:21 -04:00
|
|
|
Tag.matching_name(Array(names).take(LIMIT_PER_MODE)) if names.present?
|
2018-11-05 12:53:25 -05:00
|
|
|
end
|
|
|
|
end
|