Skip to content

諸々のリファクタリング - #17

Merged
Ryoga-exe merged 12 commits into
mainfrom
refactor
Oct 28, 2025
Merged

諸々のリファクタリング#17
Ryoga-exe merged 12 commits into
mainfrom
refactor

Conversation

@n4mlz

@n4mlz n4mlz commented Oct 26, 2025

Copy link
Copy Markdown
Member
  • record の UUID を DB 側で採番するように
  • 複数のレコードが返ってくるクエリは order by で冪等性を保つように
  • DateTime<Utc> に統一してタイムゾーン情報を保持し、API返却はRFC3339にする
  • ログレベルの使用基準を以下に統一
    • info: 本番で出す情報(ビジネスイベント、ライフサイクル)
    • debug: デバッグ用の技術詳細(開発時の調査のみ)
    • warn: 監視対象の異常(データ整合性、ビジネスロジックエラー)
    • error: 運用対応が必要な深刻な障害(DB接続エラーなど)
  • infrastructure 層の From トレイトで panicexpect を使用せず、TryFromResult を返すように
  • json 向けに #[serde(rename_all = "camelCase")] を使用するリファクタ
  • crates/usecase/src/user/records.rs でレコードを全権取得せずクエリを厳密にしてパフォーマンスを向上

タイムゾーンに関するリファクタの詳細

  • DateTime<Utc> に統一してタイムゾーン情報を保持し、API返却はRFC3339にする

リファクタ前

  • データベース: TIMESTAMPTZ(タイムゾーン付き)
  • ドメイン/DTO: NaiveDateTime(タイムゾーンなし)
  • サーバー生成: Utc::now().naive_utc() で取得後に .naive_utc() でタイムゾーン情報を消去
updated_at: ActiveValue::Set(Utc.from_utc_datetime(record.updated_at()).into()),
  • API レスポンス: .to_string() 使用で RFC3339 未対応

リファクタ後

  • ドメイン/DTO/API をすべて DateTime<Utc> に統一し、レスポンスは .to_rfc3339() を使用
  • PostgreSQL TIMESTAMPTZ は維持
  • クライアント送信は不要で、サーバー側生成のまま(DateTime<Utc> に統一)

@n4mlz n4mlz self-assigned this Oct 26, 2025
@n4mlz n4mlz changed the title [WIP] refactor リファクタ Oct 28, 2025
@n4mlz
n4mlz marked this pull request as ready for review October 28, 2025 03:38
@n4mlz
n4mlz requested a review from Ryoga-exe October 28, 2025 03:38
@n4mlz n4mlz changed the title リファクタ 諸々のリファクタリング Oct 28, 2025

@Ryoga-exe Ryoga-exe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@Ryoga-exe
Ryoga-exe merged commit 7ed63f7 into main Oct 28, 2025
4 checks passed
@Ryoga-exe
Ryoga-exe deleted the refactor branch October 28, 2025 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants