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])
|
|
|
|
|
2020-08-25 07:39:35 -04:00
|
|
|
Status.group(:id)
|
2018-11-19 06:49:50 -05:00
|
|
|
.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
|