feat: Wiki 有無判定軽量化(#233) (#234)

#233 Backend が対応できてなかったのでそっちも対応させた.

Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #234
This commit was merged in pull request #234.
This commit is contained in:
2026-01-23 01:08:27 +09:00
parent f6de272f55
commit ef3d428a06
4 changed files with 31 additions and 14 deletions
+7 -7
View File
@@ -36,7 +36,7 @@ class PostsController < ApplicationController
render json: { posts: posts.map { |post|
post.as_json(include: { tags: { only: [:id, :category, :post_count],
methods: [:name] } }).tap do |json|
methods: [:name, :has_wiki] } }).tap do |json|
json['thumbnail'] =
if post.thumbnail.attached?
rails_storage_proxy_url(post.thumbnail, only_path: false)
@@ -59,7 +59,7 @@ class PostsController < ApplicationController
render json: (post
.as_json(include: { tags: { only: [:id, :category, :post_count],
methods: [:name] } })
methods: [:name, :has_wiki] } })
.merge(viewed:))
end
@@ -100,7 +100,7 @@ class PostsController < ApplicationController
tags = Tag.expand_parent_tags(tags)
sync_post_tags!(post, tags)
render json: post.as_json(include: { tags: { only: [:id, :category, :post_count],
methods: [:name] } }),
methods: [:name, :has_wiki] } }),
status: :created
else
render json: { errors: post.errors.full_messages }, status: :unprocessable_entity
@@ -162,7 +162,7 @@ class PostsController < ApplicationController
pts.each do |pt|
events << Event.new(
post: pt.post,
tag: pt.tag.as_json(only: [:id, :category], methods: [:name]),
tag: pt.tag.as_json(only: [:id, :category], methods: [:name, :has_wiki]),
user: pt.created_user && { id: pt.created_user.id, name: pt.created_user.name },
change_type: 'add',
timestamp: pt.created_at)
@@ -170,7 +170,7 @@ class PostsController < ApplicationController
if pt.discarded_at
events << Event.new(
post: pt.post,
tag: pt.tag.as_json(only: [:id, :category], methods: [:name]),
tag: pt.tag.as_json(only: [:id, :category], methods: [:name, :has_wiki]),
user: pt.deleted_user && { id: pt.deleted_user.id, name: pt.deleted_user.name },
change_type: 'remove',
timestamp: pt.discarded_at)
@@ -255,7 +255,7 @@ class PostsController < ApplicationController
if path.include?(tag_id)
return tag.as_json(only: [:id, :category, :post_count],
methods: [:name]).merge(children: [])
methods: [:name, :has_wiki]).merge(children: [])
end
if memo.key?(tag_id)
@@ -268,7 +268,7 @@ class PostsController < ApplicationController
children = child_ids.filter_map { |cid| build_node.(cid, new_path) }
memo[tag_id] = tag.as_json(only: [:id, :category, :post_count],
methods: [:name]).merge(children:)
methods: [:name, :has_wiki]).merge(children:)
end
root_ids.filter_map { |id| build_node.call(id, []) }