Fix/walt/admin firework next id mismatch - #43
Open
nakatashingo wants to merge 4 commits into
Open
Conversation
…ng response schema
…ensure accurate ID retrieval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
原因・変更内容
次に作成される花火IDのズレ
deleted_atを立てるのみ)で行が物理的に残るため、DBの id(シーケンス採番)は削除しても巻き戻らない/fireworks/latest-idがAPI側に未実装で常に404になり、上記の誤った計算に必ずフォールバックしていた変更内容:
openapi.yaml/api/openapi/openapi.gen.go:GET /fireworks/latest-idエンドポイントを追加api/usecase/firework_usecase.go:GetLatestFireworkIdを追加。Unscoped()で論理削除済みの行も含めてMAX(id)を取得し、DBの実際の採番値と一致させるapi/handler/firework_handler.go: 上記usecaseを呼び出すハンドラを追加admin/hooks/useFireworks.ts:fetchFireworks内にあった重複・誤りのある「表示中データからmax+1を計算」処理を削除し、常にfetchLatestId(新エンドポイント)経由で次のIDを取得するよう統一fetchLatestIdのfallbackListを必須引数化しuseCallbackの依存配列からfireworksstate を除去(fireworksに依存させたままだとfetchFireworksと相互再生成され、mount時の無限再フェッチループになるため)loadAllImagesFromLocalStorageとfetchLatestIdの直列awaitをPromise.allで並列化