このコミットが含まれているのは:
@@ -108,6 +108,8 @@ class CountsExportProjection
|
||||
end
|
||||
|
||||
def csv_display(value, key)
|
||||
return @labels.fetch('bot', '') if key == 'created_by_user' && value.nil?
|
||||
return @labels.fetch("event_type:#{ value }", value) if key == 'event_type'
|
||||
return value ? @labels.fetch('latest', 'true') : '' if key == 'is_latest'
|
||||
return @labels.fetch("kind:#{ value }", value) if key == 'kind'
|
||||
return @labels.fetch("category:#{ value }", value) if key == 'category'
|
||||
|
||||
@@ -30,6 +30,9 @@ class CountsTableExport
|
||||
@columns = params.fetch('columns', '').split(',')
|
||||
@headers = JSON.parse(params.fetch('headers', '[]'))
|
||||
raise ArgumentError unless @headers.is_a?(Array) && @headers.all? { _1.is_a?(String) }
|
||||
if @summary && @headers.any? && @headers.length != @query.axes.all.length + 1
|
||||
raise ArgumentError
|
||||
end
|
||||
|
||||
unless @summary
|
||||
if ['posts', 'tags'].include?(resource)
|
||||
@@ -71,7 +74,7 @@ class CountsTableExport
|
||||
else
|
||||
values = if @summary
|
||||
row[:values].each_with_index.map do |value, index|
|
||||
page[:axis_labels].fetch("a#{ index }", {}).fetch(value.to_s, value)
|
||||
summary_value(value, index, page)
|
||||
end + [row[:count]]
|
||||
elsif @projection
|
||||
@projection.csv_record(record, row)
|
||||
@@ -91,11 +94,29 @@ class CountsTableExport
|
||||
private
|
||||
|
||||
def summary_headers
|
||||
return @headers if @headers.any?
|
||||
|
||||
labels = @labels
|
||||
@query.axes.all.map { labels.fetch(_1['field'], _1['field']) } +
|
||||
[labels.fetch('count', 'count')]
|
||||
end
|
||||
|
||||
def summary_value(value, index, page)
|
||||
field = @query.axes.all.fetch(index).fetch('field')
|
||||
return @labels.fetch('bot', '') if field == 'user' && value.nil?
|
||||
|
||||
names = page[:axis_labels].fetch("a#{ index }", {})
|
||||
name = field == 'user' ? names[value.to_s] : names.fetch(value.to_s, value)
|
||||
if field == 'user'
|
||||
name = @labels.fetch('notRegistered', '') if name.nil? || name == ''
|
||||
pattern = @labels.fetch('actorFormat', '{{name}} (#{{id}})')
|
||||
return pattern.gsub(/\{\{(name|id)\}\}/) do
|
||||
Regexp.last_match(1) == 'name' ? name.to_s : value.to_s
|
||||
end
|
||||
end
|
||||
@labels.fetch("#{ field }:#{ value }", name)
|
||||
end
|
||||
|
||||
def project(row)
|
||||
return { row: row[:values].first(@query.axes.rows.length),
|
||||
column: row[:values].drop(@query.axes.rows.length), count: row[:count] } if @summary
|
||||
@@ -148,6 +169,7 @@ class CountsTableExport
|
||||
end
|
||||
|
||||
def csv_logical(key, value)
|
||||
return @labels.fetch('bot', '') if key == 'created_by_user' && value.nil?
|
||||
return value ? @labels.fetch('latest', '') : '' if key == 'is_latest'
|
||||
if value.is_a?(Time) || value.is_a?(ActiveSupport::TimeWithZone)
|
||||
return @query.population.timezone.utc_to_local(value.utc).iso8601
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする