Persist current world history
All checks were successful
build-windows-exe / build (push) Successful in 1m50s
All checks were successful
build-windows-exe / build (push) Successful in 1m50s
This commit is contained in:
@@ -25,6 +25,7 @@ type WorldVisit struct {
|
||||
type worldHistorySnapshot struct {
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Visits []WorldVisit `json:"visits"`
|
||||
Current *WorldVisit `json:"current,omitempty"`
|
||||
}
|
||||
|
||||
type WorldHistoryTracker struct {
|
||||
@@ -61,6 +62,10 @@ func (t *WorldHistoryTracker) load() error {
|
||||
return err
|
||||
}
|
||||
t.visits = mergeWorldVisits(snap.Visits)
|
||||
if snap.Current != nil && !snap.Current.StartedAt.IsZero() {
|
||||
current := *snap.Current
|
||||
t.current = ¤t
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -188,6 +193,7 @@ func (t *WorldHistoryTracker) persistLocked() error {
|
||||
return enc.Encode(worldHistorySnapshot{
|
||||
UpdatedAt: time.Now(),
|
||||
Visits: mergeWorldVisits(t.visits),
|
||||
Current: t.current,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user