Skip to content

Conversation

@buty4649
Copy link
Contributor

概要

oneclit event listの出力にevent_type(イベント種別名)を追加し、EventTypeのマッピング処理を最適化しました。

変更内容

機能追加

  • Event構造体にEventTypeフィールドを追加
  • oneclit event listの出力にevent_type(イベント種別名)を表示

最適化

  • EventTypeのIDとnameのマッピング処理を共通関数に集約
    • EventTypeIDNameMap: ID → name のマッピング
    • EventTypeNameIDMap: name → ID のマッピング
  • GetEventTypesにキャッシュ機能を追加してAPI呼び出しを最適化

テスト

  • 新しい機能に対応したテストケースの追加・修正
  • EventTypeフィールドの検証を追加

動作確認

# イベント一覧を取得(event_typeフィールドが追加される)
oneclit event list

# 出力例
[
  {
    "id": 1,
    "event_type_id": 1,
    "event_type": "User Login",
    "user_name": "testuser",
    ...
  }
]

技術的な改善点

  1. 共通化: 複数箇所で同じマッピング処理をしていた部分を共通関数に集約
  2. キャッシュ: GetEventTypesのAPI呼び出しを1回だけに最適化
  3. 保守性: コードの重複を削減し、保守性を向上

buty4649 added 9 commits June 27, 2025 18:42
…pe mapping

- Add EventType field to Event struct for human-readable event type names
- Create common mapping functions EventTypeIDNameMap and EventTypeNameIDMap
- Add caching to GetEventTypes to avoid multiple API calls
- Update tests to include EventType field validation
- Refactor event type mapping logic to use common functions
@buty4649 buty4649 enabled auto-merge June 27, 2025 10:53
@buty4649 buty4649 merged commit 1f5fb75 into main Jun 27, 2025
2 checks passed
@buty4649 buty4649 deleted the add-events-subcommand branch June 27, 2025 10:54
@pepabo-pr-maker pepabo-pr-maker bot mentioned this pull request Jun 27, 2025
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