このコミットが含まれているのは:
@@ -195,9 +195,10 @@ class CountsPopulation
|
||||
end
|
||||
return unless params['tags'].present?
|
||||
|
||||
refs = PostTagSearch.parse_references(params, params['tags'].split)
|
||||
raw = params['tags']
|
||||
literals = PostTagSearch.literals(nil, raw, references: refs)
|
||||
tokens = raw.split.reject { _1.downcase == 'type:or' }
|
||||
refs = PostTagSearch.parse_references(params, tokens, partial: true)
|
||||
literals = PostTagSearch.literals(nil, tokens.join(' '), references: refs)
|
||||
predicates = literals.map do |literal|
|
||||
reference = literal[:reference]
|
||||
expression = if reference
|
||||
|
||||
@@ -57,7 +57,7 @@ class CountsTableQuery
|
||||
end
|
||||
|
||||
def metadata
|
||||
{ population_count: nil, population_count_computed: false,
|
||||
{ condition_labels: condition_labels, population_count: nil, population_count_computed: false,
|
||||
excluded_count: nil, excluded_count_scope: 'current_query',
|
||||
population_count_scope: 'all_recorded_versions',
|
||||
page:, limit:, execution_at: population.at.iso8601(6), at: @params['at'].presence,
|
||||
@@ -378,6 +378,21 @@ class CountsTableQuery
|
||||
end
|
||||
end
|
||||
|
||||
def condition_labels
|
||||
entries = QueryState.records(@params, 'conditions').select { _1['operator'] == 'axis_eq' }
|
||||
entries += QueryState.records(@params, 'drill')
|
||||
entries.group_by { _1['field'] }.to_h do |field, conditions|
|
||||
values = conditions.map { _1['value'] }.compact.uniq
|
||||
labels = case field
|
||||
when 'tags' then tag_labels(values)
|
||||
when 'user'
|
||||
User.where(id: values).pluck(:id, :name).to_h.transform_keys(&:to_s)
|
||||
else {}
|
||||
end
|
||||
[field, labels]
|
||||
end
|
||||
end
|
||||
|
||||
def axis_labels(records, column_values)
|
||||
result = {}
|
||||
@axis_names = {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Shared literal parsing and reference resolution for current and snapshot post search.
|
||||
class PostTagSearch
|
||||
def self.parse_references(raw, literals)
|
||||
def self.parse_references(raw, literals, partial: false)
|
||||
return nil unless raw.key?('tag_refs')
|
||||
|
||||
references = QueryState.records(raw, 'tag_refs')
|
||||
@@ -15,6 +15,16 @@ class PostTagSearch
|
||||
end
|
||||
raise ArgumentError unless valid
|
||||
|
||||
if partial
|
||||
remaining = references.dup
|
||||
result = literals.map do |literal|
|
||||
index = remaining.index { _1['name'] == literal }
|
||||
index ? remaining.delete_at(index) : nil
|
||||
end
|
||||
raise ArgumentError if remaining.any?
|
||||
|
||||
return result
|
||||
end
|
||||
references.map { _1['name'] } == literals ? references : nil
|
||||
end
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする