Skip to content

Commit 695a7e4

Browse files
hatappiclaude
andauthored
Refactor GraphQL time fields from Duration to Int seconds (#285)
* Refactor event time fields from Duration to Int seconds - Change remainingTime/elapsedTime to remainingTimeSec/elapsedTimeSec in GraphQL schema - Update GraphQL fragments and generated code to use seconds instead of Duration - Modify conversion functions to handle time.Duration to seconds conversion - Simplify JSON marshaling by removing custom Duration handling This change improves API consistency and removes complex Duration marshaling logic. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Refactor Pomodoro time fields to use seconds instead of Duration - Updated GraphQL schema and fragments to replace remainingTime and elapsedTime with remainingTimeSec and elapsedTimeSec as integers. - Modified conversion functions to handle time.Duration to seconds conversion. - Removed custom Duration marshaling logic and associated tests for simplification. This change enhances API consistency and reduces complexity in time handling. --------- Co-authored-by: Claude <[email protected]>
1 parent 89ba73e commit 695a7e4

File tree

15 files changed

+212
-834
lines changed

15 files changed

+212
-834
lines changed

internal/client/graphql/conv/event.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func toPomodoroEvent(
5858
BaseEvent: baseEvent,
5959
ID: payload.Id,
6060
State: state,
61-
RemainingTime: payload.RemainingTime,
62-
ElapsedTime: payload.ElapsedTime,
61+
RemainingTime: time.Duration(payload.RemainingTimeSec) * time.Second,
62+
ElapsedTime: time.Duration(payload.ElapsedTimeSec) * time.Second,
6363
TaskID: payload.TaskId,
6464
Phase: phase,
6565
PhaseCount: payload.PhaseCount,

internal/client/graphql/conv/pomodoro.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package conv
33

44
import (
55
"fmt"
6+
"time"
67

78
gqlgen "github.com/hatappi/gomodoro/internal/client/graphql/generated"
89
"github.com/hatappi/gomodoro/internal/core"
@@ -28,8 +29,8 @@ func ToCorePomodoro(pomodoro gqlgen.PomodoroDetails) (*core.Pomodoro, error) {
2829
TaskID: pomodoro.TaskId,
2930
Phase: phase,
3031
PhaseCount: pomodoro.PhaseCount,
31-
RemainingTime: pomodoro.RemainingTime,
32-
ElapsedTime: pomodoro.ElapsedTime,
32+
RemainingTime: time.Duration(pomodoro.RemainingTimeSec) * time.Second,
33+
ElapsedTime: time.Duration(pomodoro.ElapsedTimeSec) * time.Second,
3334
}, nil
3435
}
3536

internal/client/graphql/fragments/event.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ fragment EventDetails on Event {
1010
fragment EventPomodoroPayloadDetails on EventPomodoroPayload {
1111
id
1212
state
13-
remainingTime
14-
elapsedTime
13+
remainingTimeSec
14+
elapsedTimeSec
1515
taskId
1616
phase
1717
phaseCount

internal/client/graphql/fragments/pomodoro.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ fragment PomodoroDetails on Pomodoro {
55
startTime
66
phase
77
phaseCount
8-
remainingTime
9-
elapsedTime
8+
remainingTimeSec
9+
elapsedTimeSec
1010
}

0 commit comments

Comments
 (0)