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

This commit is contained in:
2026-05-03 03:14:32 +09:00
118 changed files with 9211 additions and 912 deletions
@@ -0,0 +1,24 @@
# frozen_string_literal: true
module MaterialRepr
BASE = { only: [:id, :url, :created_at, :updated_at],
methods: [:content_type],
include: { tag: TagRepr::BASE,
created_by_user: UserRepr::BASE,
updated_by_user: UserRepr::BASE } }.freeze
module_function
def base material, host:
material.as_json(BASE).merge(
file: if material.file.attached?
Rails.application.routes.url_helpers.rails_storage_proxy_url(
material.file, host:)
end)
end
def many materials, host:
materials.map { |m| base(m, host:) }
end
end
+4 -5
View File
@@ -3,15 +3,14 @@
module TagRepr
BASE = { only: [:id, :category, :post_count, :created_at, :updated_at],
methods: [:name, :has_wiki] }.freeze
methods: [:name, :has_wiki, :material_id] }.freeze
module_function
def base tag
tag.as_json(BASE)
tag.as_json(BASE).merge(aliases: tag.snapshot_aliases,
parents: tag.parents.map { _1.as_json(BASE) })
end
def many tags
tags.map { |t| base(t) }
end
def many(tags) = tags.map { |t| base(t) }
end