Skip to content

Commit 71ba523

Browse files
committed
fix: store activity timestamps in UTC
Convert timestamps to UTC before storing to ensure consistent timezone handling. Previously local time was stored without timezone marker, causing times to appear in the future when displayed.
1 parent 279a26f commit 71ba523

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

internal/database/repositories/jetstream_activity.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,20 @@ func (r *JetstreamActivityRepository) LogActivityWithStatus(
5858
var sqlStr string
5959
var timestampStr string
6060

61+
// Always store in UTC for consistency
62+
utcTime := timestamp.UTC()
63+
6164
switch r.db.Dialect() {
6265
case database.PostgreSQL:
63-
timestampStr = timestamp.Format(time.RFC3339)
66+
timestampStr = utcTime.Format(time.RFC3339)
6467
sqlStr = fmt.Sprintf(`INSERT INTO jetstream_activity
6568
(timestamp, operation, collection, did, status, event_json)
6669
VALUES (%s, %s, %s, %s, %s, %s)
6770
RETURNING id`,
6871
r.db.Placeholder(1), r.db.Placeholder(2), r.db.Placeholder(3),
6972
r.db.Placeholder(4), r.db.Placeholder(5), r.db.Placeholder(6))
7073
default:
71-
timestampStr = timestamp.Format("2006-01-02 15:04:05")
74+
timestampStr = utcTime.Format("2006-01-02 15:04:05")
7275
sqlStr = fmt.Sprintf(`INSERT INTO jetstream_activity
7376
(timestamp, operation, collection, did, status, event_json)
7477
VALUES (%s, %s, %s, %s, %s, %s)`,

0 commit comments

Comments
 (0)