このコミットが含まれているのは:
@@ -24,7 +24,12 @@ class NicoTagsController < ApplicationController
|
|||||||
ExternalTag
|
ExternalTag
|
||||||
.joins("LEFT JOIN (#{ post_tag_max_sql }) post_tag_max " \
|
.joins("LEFT JOIN (#{ post_tag_max_sql }) post_tag_max " \
|
||||||
'ON post_tag_max.external_tag_id = external_tags.id')
|
'ON post_tag_max.external_tag_id = external_tags.id')
|
||||||
q = q.where('external_tags.name LIKE ?', "%#{ name }%") if name
|
if name
|
||||||
|
q = q.where(('external_tags.name LIKE ? ' +
|
||||||
|
"OR CONCAT(external_tags.platform, ':', external_tags.name) LIKE ?"),
|
||||||
|
"%#{ name }%", "%#{ name }")
|
||||||
|
end
|
||||||
|
|
||||||
if linked_tag
|
if linked_tag
|
||||||
linked_tag_ids =
|
linked_tag_ids =
|
||||||
Tag
|
Tag
|
||||||
@@ -108,7 +113,10 @@ class NicoTagsController < ApplicationController
|
|||||||
updated_at: tag.created_at,
|
updated_at: tag.created_at,
|
||||||
deprecated_at: nil,
|
deprecated_at: nil,
|
||||||
aliases: [],
|
aliases: [],
|
||||||
parents: [] }
|
parents: [],
|
||||||
|
has_wiki: false,
|
||||||
|
material_id: nil,
|
||||||
|
has_deerjikists: false }
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_nico_tag_form_record_invalid record
|
def render_nico_tag_form_record_invalid record
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ class PostVersionsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
post_id = params[:post].presence
|
post_id = params[:post].presence
|
||||||
tag_id = params[:tag].presence&.to_i
|
tag_id = params[:tag].presence&.to_i
|
||||||
|
external_tag_id = params[:external_tag].presence&.to_i
|
||||||
|
return head :bad_request if tag_id && external_tag_id
|
||||||
|
|
||||||
page = (params[:page].presence || 1).to_i
|
page = (params[:page].presence || 1).to_i
|
||||||
limit = (params[:limit].presence || 20).to_i
|
limit = (params[:limit].presence || 20).to_i
|
||||||
|
|
||||||
@@ -26,7 +29,12 @@ class PostVersionsController < ApplicationController
|
|||||||
'prev.original_created_from AS prev_original_created_from',
|
'prev.original_created_from AS prev_original_created_from',
|
||||||
'prev.original_created_before AS prev_original_created_before')
|
'prev.original_created_before AS prev_original_created_before')
|
||||||
q = q.where('post_versions.post_id = ?', post_id) if post_id
|
q = q.where('post_versions.post_id = ?', post_id) if post_id
|
||||||
if tag_id
|
if external_tag_id || (tag_id && !(Tag.exists?(id: tag_id)))
|
||||||
|
q = q.where('JSON_CONTAINS(post_versions.tags_json,' +
|
||||||
|
"JSON_OBJECT('external_tag_id', #{ external_tag_id })) " +
|
||||||
|
'OR JSON_CONTAINS(prev.tags_json,' +
|
||||||
|
"JSON_OBJECT('external_tag_id', #{ external_tag_id }))")
|
||||||
|
elsif tag_id
|
||||||
q = q.where("JSON_CONTAINS(post_versions.tags_json, JSON_OBJECT('tag_id', #{ tag_id })) " +
|
q = q.where("JSON_CONTAINS(post_versions.tags_json, JSON_OBJECT('tag_id', #{ tag_id })) " +
|
||||||
"OR JSON_CONTAINS(prev.tags_json, JSON_OBJECT('tag_id', #{ tag_id }))")
|
"OR JSON_CONTAINS(prev.tags_json, JSON_OBJECT('tag_id', #{ tag_id }))")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -505,7 +505,10 @@ class PostsController < ApplicationController
|
|||||||
memo[tag_id] = TagRepr.inline(tag).merge(children:, sections:)
|
memo[tag_id] = TagRepr.inline(tag).merge(children:, sections:)
|
||||||
end
|
end
|
||||||
|
|
||||||
root_ids.filter_map { |id| build_node.call(id, []) }
|
internal_tags = root_ids.filter_map { |id| build_node.call(id, []) }
|
||||||
|
external_tags =
|
||||||
|
post.external_tags.map { ExternalTagRepr.inline(_1).merge(children: [], sections: []) }
|
||||||
|
internal_tags + external_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def sibling_posts_by_parent parent_post_ids
|
def sibling_posts_by_parent parent_post_ids
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
module ExternalTagRepr
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def base tag
|
||||||
|
{ 'id' => tag.id,
|
||||||
|
'name' => "#{ tag.platform }:#{ tag.name }",
|
||||||
|
'category' => 'nico',
|
||||||
|
'post_count' => tag.post_count,
|
||||||
|
'created_at' => tag.created_at,
|
||||||
|
'updated_at' => tag.created_at,
|
||||||
|
'deprecated_at' => nil,
|
||||||
|
'aliases' => [],
|
||||||
|
'parents' => [],
|
||||||
|
'has_wiki' => false,
|
||||||
|
'material_id' => nil,
|
||||||
|
'has_deerjikists' => false }
|
||||||
|
end
|
||||||
|
|
||||||
|
def inline(tag) = base(tag)
|
||||||
|
end
|
||||||
@@ -87,15 +87,24 @@ module PostRepr
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag_json post
|
def tag_json post
|
||||||
post
|
internal_tags =
|
||||||
|
post
|
||||||
.post_tags
|
.post_tags
|
||||||
.reject { _1.tag.deprecated? }
|
.reject { _1.tag.deprecated? }
|
||||||
.sort_by { _1.tag.name }
|
.sort_by { _1.tag.name }
|
||||||
.map do |post_tag|
|
.map { |post_tag|
|
||||||
TagRepr.inline(post_tag.tag).merge(
|
TagRepr.inline(post_tag.tag).merge(
|
||||||
'children' => [],
|
'children' => [],
|
||||||
'sections' => post_tag.sections.as_json(only: [:begin_ms, :end_ms]))
|
'sections' => post_tag.sections.as_json(only: [:begin_ms, :end_ms]))
|
||||||
end
|
}
|
||||||
|
|
||||||
|
external_tags =
|
||||||
|
post
|
||||||
|
.external_tags
|
||||||
|
.sort_by { _1.name }
|
||||||
|
.map { ExternalTagRepr.base(_1).merge('children' => [], 'sections' => []) }
|
||||||
|
|
||||||
|
internal_tags + external_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def thumbnail_url post, host: nil
|
def thumbnail_url post, host: nil
|
||||||
|
|||||||
新しいイシューから参照
ユーザーをブロックする