このコミットが含まれているのは:
2026-10-26 21:53:09 +09:00
コミット 1154babe45
22個のファイルの変更、537行の追加、145行の削除
+6 -4
ファイルの表示
@@ -40,7 +40,7 @@ class CountsAxes
end
def expressions
all.map do |axis|
@expressions ||= all.map do |axis|
field = axis.fetch('field')
case field
when 'tags'
@@ -56,9 +56,9 @@ class CountsAxes
end
end
def joins
def joins(fields = all.map { _1['field'] })
result = ''
if all.any? { _1['field'] == 'tags' }
if fields.include?('tags')
result += <<~SQL.squish
JOIN JSON_TABLE(CAST(v.tags_json AS JSON), '$[*]' COLUMNS (
tag_id BIGINT PATH '$.tag_id' NULL ON EMPTY,
@@ -66,7 +66,7 @@ class CountsAxes
SQL
end
if all.any? { _1['field'] == 'changed_field' }
if fields.include?('changed_field')
fields = @definition.changes.map do |field|
"SELECT #{ ApplicationRecord.connection.quote(field) } AS field_key"
end.join(' UNION ALL ')
@@ -89,6 +89,8 @@ class CountsAxes
raise ArgumentError unless @definition.axes(@population.history).include?(axis['field'])
if @definition.fields[axis['field']] == :datetime
raise ArgumentError unless GRAINS.include?(axis.fetch('grain', 'month'))
axis['grain'] ||= 'month'
elsif axis.key?('grain')
raise ArgumentError
end