WIP: preserve failed Codex job issue-485-5cicl5k1

このコミットが含まれているのは:
Codex Night Worker
2026-11-18 20:58:12 +09:00
コミット a55408dc32
5個のファイルの変更、207行の追加、15行の削除
+6 -6
ファイルの表示
@@ -29,14 +29,14 @@ class PostVersionsController < ApplicationController
count = q.except(:select, :order, :limit, :offset).count
ids = q.order(Arel.sql('post_versions.created_at DESC, post_versions.id DESC'))
.limit(limit)
.offset(offset)
.pluck('post_versions.id')
versions = version_scope.merge(q).where(id: ids)
# Apply visibility and pagination before joining the previous snapshots.
page_scope = q.order(Arel.sql('post_versions.created_at DESC, post_versions.id DESC'))
.limit(limit).offset(offset).select('post_versions.*')
versions = version_scope.from(page_scope, :post_versions)
.order(Arel.sql('post_versions.created_at DESC, post_versions.id DESC'))
render json: { versions: serialise_versions(versions, locale.language_code), count:, population_count: HistoryAccess.population_count(PostVersion) }
render json: { versions: serialise_versions(versions, locale.language_code),
count:, population_count: HistoryAccess.population_count(PostVersion) }
end
private
+5 -6
ファイルの表示
@@ -41,10 +41,9 @@ class HistoryAccess < ActiveSupport::CurrentAttributes
table = model.table_name
keys = KEYS.fetch(table)
matches = keys.map { "boundary.#{ _1 } = #{ row }.#{ _1 }" }.join(' AND ')
boundaries = "SELECT #{ keys.join(', ') }, MAX(version_no) AS version_no FROM #{ table } " +
"WHERE event_type = 'discard' GROUP BY #{ keys.join(', ') }"
clauses = ["NOT EXISTS (SELECT 1 FROM (#{ boundaries }) boundary WHERE #{ matches } " +
"AND boundary.version_no >= #{ row }.version_no)"]
# Any discard at or after this version hides it, including after a restore.
clauses = ["NOT EXISTS (SELECT 1 FROM #{ table } boundary WHERE #{ matches } " +
"AND boundary.version_no >= #{ row }.version_no AND boundary.event_type = 'discard')"]
clauses += reference_sql(table, row) if references
clauses.map { "(#{ _1 })" }.join(' AND ')
end
@@ -62,8 +61,8 @@ class HistoryAccess < ActiveSupport::CurrentAttributes
# A scalar lookup avoids MySQL's semijoin rewrite losing the JSON row correlation.
"(SELECT 1 FROM JSON_TABLE(COALESCE(#{ document }, JSON_ARRAY()), " +
"'$[*]' COLUMNS (reference_id BIGINT PATH '$' NULL ON EMPTY)) reference_entry " +
"JOIN (#{ discarded_keys(table, key) }) blocked " +
"ON reference_entry.reference_id = blocked.#{ key } LIMIT 1) IS NULL"
"JOIN #{ table } blocked ON reference_entry.reference_id = blocked.#{ key } " +
"WHERE blocked.event_type = 'discard' LIMIT 1) IS NULL"
end
def self.list_reference(table, key, document)