discourse/lib/topic_query_params.rb
Natalie Tay 1b60b632f2
DEV: Use tag_name/tag.name instead of tag_id/tag.id where the name is actually used (#36226)
In plenty of areas where tags are dealt with, we use `tag_id` when
actually referring to `tag_name`. This is super confusing.

We're making some changes to how tags are dealt with, so to prevent
adding more tech debt we're fixing this confusion first.
2025-12-29 13:20:06 +08:00

20 lines
566 B
Ruby

# frozen_string_literal: true
module TopicQueryParams
def build_topic_list_options
options = {}
params[:tags] = [params[:tag_name], *Array(params[:tags])].uniq if params[:tag_name].present?
TopicQuery.public_valid_options.each do |key|
if params.key?(key) && (val = params[key]).present?
options[key] = val
raise Discourse::InvalidParameters.new key if !TopicQuery.validate?(key, val)
end
end
# hacky columns get special handling
options[:topic_ids] = param_to_integer_list(:topic_ids)
options
end
end