forked from JustaPenguin/assetto-server-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.go
83 lines (66 loc) · 2.25 KB
/
store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package servermanager
type Store interface {
// Custom Races
UpsertCustomRace(race *CustomRace) error
FindCustomRaceByID(uuid string) (*CustomRace, error)
ListCustomRaces() ([]*CustomRace, error)
DeleteCustomRace(race *CustomRace) error
// Entrants
UpsertEntrant(entrant Entrant) error
ListEntrants() ([]*Entrant, error)
DeleteEntrant(id string) error
// Server Options
UpsertServerOptions(so *GlobalServerConfig) error
LoadServerOptions() (*GlobalServerConfig, error)
// Championships
UpsertChampionship(c *Championship) error
ListChampionships() ([]*Championship, error)
LoadChampionship(id string) (*Championship, error)
DeleteChampionship(id string) error
// Live Timings
UpsertLiveTimingsData(*LiveTimingsPersistedData) error
LoadLiveTimingsData() (*LiveTimingsPersistedData, error)
UpsertLastRaceEvent(r RaceEvent) error
LoadLastRaceEvent() (RaceEvent, error)
ClearLastRaceEvent() error
UpsertLiveFrames([]string) error
ListPrevFrames() ([]string, error)
// Meta
SetMeta(key string, value interface{}) error
GetMeta(key string, out interface{}) error
// Accounts
ListAccounts() ([]*Account, error)
UpsertAccount(a *Account) error
FindAccountByName(name string) (*Account, error)
FindAccountByID(id string) (*Account, error)
DeleteAccount(id string) error
// Audit Log
GetAuditEntries() ([]*AuditEntry, error)
AddAuditEntry(entry *AuditEntry) error
// Race Weekend
ListRaceWeekends() ([]*RaceWeekend, error)
UpsertRaceWeekend(rw *RaceWeekend) error
LoadRaceWeekend(id string) (*RaceWeekend, error)
DeleteRaceWeekend(id string) error
// Stracker Options
UpsertStrackerOptions(sto *StrackerConfiguration) error
LoadStrackerOptions() (*StrackerConfiguration, error)
// KissMyRank Options
UpsertKissMyRankOptions(kmr *KissMyRankConfig) error
LoadKissMyRankOptions() (*KissMyRankConfig, error)
// RealPenalty options
UpsertRealPenaltyOptions(rpc *RealPenaltyConfig) error
LoadRealPenaltyOptions() (*RealPenaltyConfig, error)
}
func loadChampionshipRaceWeekends(championship *Championship, store Store) error {
var err error
for _, event := range championship.Events {
if event.IsRaceWeekend() {
event.RaceWeekend, err = store.LoadRaceWeekend(event.RaceWeekendID.String())
if err != nil {
return err
}
}
}
return nil
}