このコミットが含まれているのは:
2026-10-05 00:59:38 +09:00
コミット f78a08bea1
4個のファイルの変更、69行の追加、28行の削除
+8 -24
ファイルの表示
@@ -14,7 +14,7 @@ class TagDescriptionsController < ApplicationController
render json: representation(description) render json: representation(description)
end end
def create def update
return head :unauthorized unless current_user return head :unauthorized unless current_user
return head :forbidden unless current_user.gte_member? return head :forbidden unless current_user.gte_member?
@@ -24,39 +24,23 @@ class TagDescriptionsController < ApplicationController
tag = Tag.find_by(id: params[:id]) tag = Tag.find_by(id: params[:id])
return head :not_found unless tag return head :not_found unless tag
if TagDescription.exists?(tag:, language_code: 'ja') description = TagDescription.find_by(tag:, language_code: 'ja')
return render_unprocessable_entity('説明はすでに存在します.')
end
if description
TagDescriptionOperation.update!(tag:, body:, updated_by_user: current_user)
description.reload
render json: representation(description)
else
TagDescriptionOperation.create!(tag:, body:, created_by_user: current_user) TagDescriptionOperation.create!(tag:, body:, created_by_user: current_user)
description = TagDescription.find_by!(tag:, language_code: 'ja') description = TagDescription.find_by!(tag:, language_code: 'ja')
render json: representation(description), status: :created render json: representation(description), status: :created
end
rescue ActiveRecord::RecordInvalid => e rescue ActiveRecord::RecordInvalid => e
render_validation_error e.record render_validation_error e.record
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
render_record_not_unique render_record_not_unique
end end
def update
return head :unauthorized unless current_user
return head :forbidden unless current_user.gte_member?
body = params[:body].to_s
return render_unprocessable_entity('本文は必須です.', field: :body) if body.blank?
description = TagDescription.find_by(tag_id: params[:id], language_code: 'ja')
return create unless description
TagDescriptionOperation.update!(
tag: description.tag, body:, updated_by_user: current_user)
description.reload
render json: representation(description)
rescue ActiveRecord::RecordInvalid => e
render_validation_error e.record
end
private private
def representation description def representation description
+4
ファイルの表示
@@ -2,6 +2,10 @@ class WikiPagesController < ApplicationController
rescue_from Wiki::Commit::Conflict, with: :render_wiki_conflict rescue_from Wiki::Commit::Conflict, with: :render_wiki_conflict
def index def index
# 互換性のための化石リソース
# TODO: ヘルプおよびタグ・グループ追加後に,
# TODO: タグ説明とヘルプ、タグ・グループから取得する作りに変更する.
#
title = params[:title].to_s.strip title = params[:title].to_s.strip
descriptions = TagDescription.where(language_code: 'ja') descriptions = TagDescription.where(language_code: 'ja')
.includes(tag: :tag_names) .includes(tag: :tag_names)
+53
ファイルの表示
@@ -0,0 +1,53 @@
class RepairWikiUpdatedAt < ActiveRecord::Migration[8.0]
class WikiPage < ActiveRecord::Base
self.table_name = 'wiki_pages'
end
class WikiVersion < ActiveRecord::Base
self.table_name = 'wiki_versions'
end
class TagDescription < ActiveRecord::Base
self.table_name = 'tag_descriptions'
end
class TagDescriptionVersion < ActiveRecord::Base
self.table_name = 'tag_description_versions'
end
def up
say_with_time 'Repairing wiki_pages.updated_at from wiki_versions' do
WikiPage.find_each do |page|
version =
WikiVersion
.where(wiki_page_id: page.id)
.order(version_no: :desc)
.first
next unless version
page.update_columns(updated_at: version.created_at)
end
end
say_with_time 'Repairing tag_descriptions.updated_at from tag_description_versions' do
TagDescription.find_each do |description|
version =
TagDescriptionVersion
.where(
tag_id: description.tag_id,
language_code: description.language_code)
.order(version_no: :desc)
.first
next unless version
description.update_columns(updated_at: version.created_at)
end
end
end
def down
;
end
end
生成ファイル
+1 -1
ファイルの表示
@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2026_10_03_010000) do ActiveRecord::Schema[8.0].define(version: 2026_10_05_000000) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.string "record_type", null: false t.string "record_type", null: false