このコミットが含まれているのは:
@@ -31,7 +31,35 @@ class CountsResourceDefinition
|
||||
OPERATORS = {
|
||||
string: ['eq', 'ne', 'like'], enum: ['eq', 'ne'], boolean: ['eq', 'ne'],
|
||||
integer: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'range'],
|
||||
datetime: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'range'] }.freeze
|
||||
datetime: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'range'],
|
||||
interval: ['range'] }.freeze
|
||||
LABELS = {
|
||||
'resource_id' => 'counts:columns.resourceId', 'version_no' => 'counts:columns.version',
|
||||
'is_latest' => 'counts:columns.latest', 'event_type' => 'counts:eventType',
|
||||
'user' => 'history:actor', 'created_at' => 'counts:columns.changedAt',
|
||||
'thumbnail' => 'counts:columns.thumbnailDisplay',
|
||||
'thumbnail_base' => 'counts:columns.thumbnailURL',
|
||||
'title' => 'counts:columns.postTitle', 'url' => 'counts:columns.postURL',
|
||||
'tags' => 'counts:columns.tags', 'tags_json' => 'counts:columns.tags',
|
||||
'video_ms' => 'shared:labels.duration', 'name' => 'counts:columns.name',
|
||||
'names' => 'counts:columns.names', 'category' => 'common:categoryLabel',
|
||||
'aliases' => 'tags:aliases', 'deprecated' => 'counts:columns.deprecated',
|
||||
'original_created_from' => 'counts:columns.originalFrom',
|
||||
'original_created_before' => 'counts:columns.originalBefore',
|
||||
'language_code' => 'counts:columns.language' }.freeze
|
||||
CHILD_LABELS = {
|
||||
'id' => 'counts:columns.resourceId', 'versionNo' => 'history:version',
|
||||
'kind' => 'counts:columns.kind', 'name' => 'history:name',
|
||||
'category' => 'common:categoryLabel', 'sections' => 'counts:columns.sections',
|
||||
'names' => 'counts:columns.names', 'aliases' => 'tags:aliases',
|
||||
'languageCode' => 'counts:columns.language',
|
||||
'scriptCode' => 'history:nameChanges.script',
|
||||
'autoGenerated' => 'history:nameChanges.automatic',
|
||||
'tagId' => 'counts:attributes.tag_id', 'tagGroupId' => 'counts:resources.tag_groups',
|
||||
'sectionName' => 'counts:attributes.section_name',
|
||||
'description' => 'counts:attributes.description',
|
||||
'children' => 'counts:attributes.children', 'profile' => 'counts:attributes.profile',
|
||||
'path' => 'counts:attributes.path' }.freeze
|
||||
|
||||
attr_reader :model, :keys, :fields, :resource
|
||||
|
||||
@@ -62,4 +90,57 @@ class CountsResourceDefinition
|
||||
operators: OPERATORS.fetch(type, []) }
|
||||
end
|
||||
end
|
||||
|
||||
def field_label(key) = LABELS.fetch(key, "counts:attributes.#{ key }")
|
||||
|
||||
def output_fields
|
||||
content = case resource
|
||||
when 'posts'
|
||||
['thumbnail', 'title', 'url', 'thumbnail_base', 'tags', 'parents', 'video_ms',
|
||||
'original_created_from', 'original_created_before']
|
||||
when 'tags' then ['name', 'names', 'category', 'aliases', 'parents', 'deprecated']
|
||||
else fields.keys - COMMON.keys
|
||||
end
|
||||
keys = ['resource_id', 'version_no', 'is_latest'] + (content - ['thumbnail']) +
|
||||
['event_type', 'user', 'created_at']
|
||||
keys.unshift('thumbnail') if content.include?('thumbnail')
|
||||
keys.map do |key|
|
||||
label = if key == 'parents'
|
||||
resource == 'tags' ? 'tags:parents' : 'shared:labels.parentPosts'
|
||||
else field_label(key)
|
||||
end
|
||||
field = { key:, label: }
|
||||
children = child_fields(key)
|
||||
field[:children] = children if children.any?
|
||||
field
|
||||
end
|
||||
end
|
||||
|
||||
def child_fields(key, depth = 4)
|
||||
keys = case key
|
||||
when 'tags' then ['id', 'versionNo', 'kind', 'name', 'category', 'sections', 'names']
|
||||
when 'names' then ['languageCode', 'scriptCode', 'name', 'aliases', 'autoGenerated']
|
||||
when 'aliases'
|
||||
resource == 'tags' ? ['languageCode', 'name', 'scriptCode'] : ['name', 'scriptCode']
|
||||
when 'parents' then resource == 'tags' ? ['id', 'name'] : ['id']
|
||||
when 'members' then ['tagId', 'tagGroupId', 'versionNo']
|
||||
when 'export_paths_json' then ['profile', 'path']
|
||||
when 'placements', 'children'
|
||||
scalar = ['sectionName', 'description', 'tagId', 'tagGroupId']
|
||||
scalar + (depth > 0 ? ['children'] : [])
|
||||
else []
|
||||
end
|
||||
keys.map do |child|
|
||||
label = key == 'members' && child == 'tagId' ?
|
||||
'counts:columns.resourceId' : CHILD_LABELS.fetch(child)
|
||||
field = { key: child, label: }
|
||||
children = child_fields(child, child == 'children' ? depth - 1 : depth)
|
||||
# Language is attached to top-level aliases, not to aliases inside a language entry.
|
||||
children = children.reject { _1[:key] == 'languageCode' } if child == 'aliases'
|
||||
field[:children] = children if children.any?
|
||||
field
|
||||
end
|
||||
end
|
||||
|
||||
def filter_metadata = @filter_metadata ||= CountsCondition.fields(self)
|
||||
end
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする