タグ一覧ページの作成(#61) (#298)

#61

#61

Merge remote-tracking branch 'origin/main' into feature/061

#61

#61

#61

#61

#61

#61

#61

#61

#61

#61

日づけ不詳の表示修正

Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #298
This commit was merged in pull request #298.
This commit is contained in:
2026-03-21 19:58:02 +09:00
parent 8cf7107445
commit ee93ff8ea0
26 changed files with 1135 additions and 283 deletions
+9 -5
View File
@@ -2,15 +2,19 @@
module PostRepr
BASE = { include: { tags: TagRepr::BASE } }.freeze
BASE = { include: { tags: TagRepr::BASE, uploaded_user: UserRepr::BASE } }.freeze
module_function
def base post
post.as_json(BASE)
def base post, current_user = nil
json = post.as_json(BASE)
return json.merge(viewed: false) unless current_user
viewed = current_user.viewed?(post)
json.merge(viewed:)
end
def many posts
posts.map { |p| base(p) }
def many posts, current_user = nil
posts.map { |p| base(p, current_user) }
end
end
+2 -1
View File
@@ -2,7 +2,8 @@
module TagRepr
BASE = { only: [:id, :category, :post_count], methods: [:name, :has_wiki] }.freeze
BASE = { only: [:id, :category, :post_count, :created_at, :updated_at],
methods: [:name, :has_wiki] }.freeze
module_function
+16
View File
@@ -0,0 +1,16 @@
# frozen_string_literal: true
module UserRepr
BASE = { only: [:id, :name] }.freeze
module_function
def base user
user.as_json(BASE)
end
def many users
users.map { |u| base(u) }
end
end