コミットを比較

..
1 コミット
作成者 SHA1 メッセージ 日付
Codex Night Worker 4751b64416 AI: address issue #242 2026-11-16 00:27:35 +09:00
5個のファイルの変更、27行の追加、131行の削除
+5
ファイルの表示
@@ -0,0 +1,5 @@
class AddIndexToTagsPostCount < ActiveRecord::Migration[8.0]
def change
add_index :tags, :post_count
end
end
生成ファイル
+2 -1
ファイルの表示
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2026_11_08_020000) do
ActiveRecord::Schema[8.0].define(version: 2026_11_16_000000) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -629,6 +629,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_11_08_020000) do
t.integer "post_count", default: 0, null: false
t.integer "version_no", null: false
t.index ["deprecated_at"], name: "index_tags_on_deprecated_at"
t.index ["post_count"], name: "index_tags_on_post_count"
t.check_constraint "(`deprecated_at` is null) or (`category` <> _utf8mb4'nico')", name: "chk_tags_deprecated_at_not_nico"
t.check_constraint "`version_no` > 0", name: "chk_tags_version_no_positive"
end
+11
ファイルの表示
@@ -2,6 +2,17 @@ require 'rails_helper'
RSpec.describe Tag, type: :model do
include WikiRecords
describe 'database indexes' do
it 'has a non-unique index on post_count' do
indexes = described_class.connection.indexes(described_class.table_name)
index = indexes.find { |entry| entry.columns == ['post_count'] }
expect(index).to be_present
expect(index.unique).to be(false)
end
end
describe '#has_description?' do
let(:tag) { create(:tag) }
-120
ファイルの表示
@@ -1,120 +0,0 @@
import { act, cleanup, render } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { GekanatorBackdrop } from '@/pages/GekanatorPage'
import { buildPost } from '@/test/factories'
import type { CSSProperties, ReactNode } from 'react'
vi.mock ('framer-motion', async importOriginal => ({
...await importOriginal<typeof import ('framer-motion')> (),
motion: {
div: (
{ children, animate: animation, initial, transition, style }: {
children?: ReactNode
animate?: { scale?: number; rotateY?: number }
initial?: { rotateY?: number }
transition?: { duration?: number }
style?: CSSProperties },
) => (
<div
data-scale={animation?.scale}
data-rotation={animation?.rotateY}
data-initial-rotation={initial?.rotateY}
data-duration={transition?.duration}
data-columns={style?.gridTemplateColumns}>
{children}
</div>) } }))
const target = buildPost ({ id: 1, thumbnail: 'https://example.com/target.jpg' })
const candidates = [
buildPost ({ id: 2, thumbnail: 'https://example.com/second.jpg' }),
buildPost ({ id: 3, thumbnail: 'https://example.com/third.jpg' })]
const candidateThumbnails = candidates.map (post => post.thumbnail)
describe.each ([
{ motionMode: 'on', duration: 450, columns: 10 },
{ motionMode: 'calm', duration: 600, columns: 7 }] as const) (
'GekanatorBackdrop winning-run collapse ($motionMode)',
({ motionMode, duration, columns }) => {
const props = {
posts: [target],
mascotAsset: '/mascot.png',
phase: 'question' as const,
visualSeed: 'winning-run',
motionMode,
winningRunTargetPost: target,
winningRunQuestionCount: 2 }
beforeEach (() => {
vi.useFakeTimers ()
})
afterEach (() => {
cleanup ()
vi.useRealTimers ()
})
it ('flips the old target to normal candidates before restoring the scale', () => {
const { container, rerender } = render (<GekanatorBackdrop {...props}/>)
expect (container.querySelector ('[data-scale]')).toHaveAttribute ('data-scale', '2')
expect (container.querySelectorAll ('[data-rotation]')).toHaveLength (0)
rerender (<GekanatorBackdrop {...props}
posts={candidates}
visualSeed="collapsed"
winningRunTargetPost={null}
winningRunQuestionCount={0}/>)
const flips = container.querySelectorAll ('[data-rotation="180"]')
expect (flips).toHaveLength (9 * 8 * 8)
for (const flip of flips) {
const images = flip.querySelectorAll ('img')
expect (flip).toHaveAttribute ('data-initial-rotation', '0')
expect (flip).toHaveAttribute ('data-duration', String (duration / 1000))
expect (images).toHaveLength (2)
expect (candidateThumbnails).toContain (images[0].getAttribute ('src'))
expect (images[1]).toHaveAttribute ('src', target.thumbnail)
}
expect (container.querySelector ('[data-scale]')).toHaveAttribute ('data-scale', '2')
act (() => { vi.advanceTimersByTime (duration - 1) })
expect (container.querySelectorAll ('[data-rotation="180"]')).toHaveLength (flips.length)
act (() => { vi.advanceTimersByTime (1) })
expect (container.querySelectorAll ('[data-rotation]')).toHaveLength (0)
expect (container.querySelector ('[data-scale]')).toHaveAttribute ('data-scale', '1')
expect (container.querySelector ('[data-columns]')).toHaveAttribute (
'data-columns', `repeat(${ columns }, minmax(0, 1fr))`)
const images = container.querySelectorAll ('img')
expect (images).toHaveLength (9 * columns * columns)
for (const image of images)
expect (candidateThumbnails).toContain (image.getAttribute ('src'))
})
it ('cancels the collapse when a winning run resumes during the flip', () => {
const { container, rerender } = render (<GekanatorBackdrop {...props}/>)
rerender (<GekanatorBackdrop {...props}
posts={candidates}
visualSeed="collapsed"
winningRunTargetPost={null}
winningRunQuestionCount={0}/>)
expect (container.querySelectorAll ('[data-rotation="180"]')).toHaveLength (9 * 8 * 8)
act (() => { vi.advanceTimersByTime (duration / 2) })
rerender (<GekanatorBackdrop {...props}
posts={candidates}
visualSeed="resumed"
winningRunTargetPost={candidates[0]}
winningRunQuestionCount={1}/>)
expect (container.querySelectorAll ('[data-rotation]')).toHaveLength (0)
act (() => { vi.advanceTimersByTime (duration) })
expect (container.querySelector ('[data-scale]')).toHaveAttribute (
'data-scale', String (8 / 6))
const images = container.querySelectorAll ('img')
expect (images).toHaveLength (9 * 8 * 8)
for (const image of images)
expect (image).toHaveAttribute ('src', candidates[0].thumbnail)
})
})
+9 -10
ファイルの表示
@@ -3203,7 +3203,7 @@ const backgroundPostsFor = ({
}
export const GekanatorBackdrop: FC<{
const GekanatorBackdrop: FC<{
posts: Post[]
mascotAsset: string
phase: Phase
@@ -3362,9 +3362,6 @@ export const GekanatorBackdrop: FC<{
const renderedSettings = settingsForMode (displayedBackdropMode)
const renderedTileCount = renderedSettings.columns * renderedSettings.rows
const renderedScale = scaleForMode (displayedBackdropMode, displayedWinningRunCount)
const tileFlipAllowed =
displayedBackdropMode === 'normal'
|| (displayedBackdropMode === 'winning_run' && backdropMode === 'normal')
const isGuessPresentation =
backdropMode === 'guess' || displayedBackdropMode === 'guess'
@@ -3612,14 +3609,16 @@ export const GekanatorBackdrop: FC<{
? toThumbnails[index % Math.max (toThumbnails.length, 1)]
: currentThumbnail
const thumbnail =
tileFlipAllowed
? currentThumbnail
: nextThumbnails[index % Math.max (nextThumbnails.length, 1)]
displayedBackdropMode === 'winning_run'
|| displayedBackdropMode === 'guess'
? nextThumbnails[index % Math.max (nextThumbnails.length, 1)]
: currentThumbnail
if (!(thumbnail) || !(frontThumbnail) || !(backThumbnail))
return null
const imageSource = ['intro', 'end'].includes (phase) ? mascotAsset : thumbnail
const staticTile = !tileFlipAllowed || !isFlippingTiles
const showStaticTile =
displayedBackdropMode !== 'normal' || !(isFlippingTiles)
return (
<motion.div
@@ -3628,14 +3627,14 @@ export const GekanatorBackdrop: FC<{
layout={displayedBackdropMode !== 'normal'}
transition={{ duration: tileFlipDuration, ease: 'easeInOut' }}
style={{ perspective: 1600 }}>
{staticTile && (
{showStaticTile && (
<img
src={imageSource}
alt=""
className="absolute inset-0 h-full w-full object-cover"
style={{ opacity: renderedSettings.opacity }}/>)
}
{!staticTile && (
{!(showStaticTile) && (
<motion.div
className="absolute inset-0"
initial={{ rotateY: 0 }}