Skip to content

Commit

Permalink
fix go side of db code to comply with new types
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Sep 26, 2023
1 parent c643bbc commit fa9c5c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions app/resources/server/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (s *DB) Upsert(ctx context.Context, e All) error {
Update(
db.Server.IP.Set(e.IP),
db.Server.Hn.Set(e.Core.Hostname),
db.Server.Pc.Set(e.Core.Players),
db.Server.Pm.Set(e.Core.MaxPlayers),
db.Server.Pc.Set(db.BigInt(e.Core.Players)),
db.Server.Pm.Set(db.BigInt(e.Core.MaxPlayers)),
db.Server.Gm.Set(e.Core.Gamemode),
db.Server.La.Set(e.Core.Language),
db.Server.Pa.Set(e.Core.Password),
Expand All @@ -60,14 +60,14 @@ func (s *DB) Upsert(ctx context.Context, e All) error {
if svr, err = s.client.Server.CreateOne(
db.Server.IP.Set(e.IP),
db.Server.Hn.Set(e.Core.Hostname),
db.Server.Pc.Set(e.Core.Players),
db.Server.Pm.Set(e.Core.MaxPlayers),
db.Server.Pc.Set(db.BigInt(e.Core.Players)),
db.Server.Pm.Set(db.BigInt(e.Core.MaxPlayers)),
db.Server.Gm.Set(e.Core.Gamemode),
db.Server.La.Set(e.Core.Language),
db.Server.Pa.Set(e.Core.Password),
db.Server.Vn.Set(e.Core.Version),
db.Server.Omp.Set(e.Core.IsOmp),
db.Server.Active.Set(e.Active),
db.Server.Omp.Set(e.Core.IsOmp),
db.Server.Domain.SetOptional(e.Domain),
db.Server.Description.SetOptional(e.Description),
db.Server.Banner.SetOptional(e.Banner),
Expand Down
8 changes: 4 additions & 4 deletions app/resources/server/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type All struct {
type Essential struct {
IP string `json:"ip"`
Hostname string `json:"hn"`
Players int `json:"pc"`
MaxPlayers int `json:"pm"`
Players int64 `json:"pc"`
MaxPlayers int64 `json:"pm"`
Gamemode string `json:"gm"`
Language string `json:"la"`
Password bool `json:"pa"`
Expand Down Expand Up @@ -90,8 +90,8 @@ func dbToAPI(r db.ServerModel) *All {
Core: Essential{
IP: r.IP,
Hostname: r.Hn,
Players: r.Pc,
MaxPlayers: r.Pm,
Players: int64(r.Pc),
MaxPlayers: int64(r.Pm),
Gamemode: r.Gm,
Language: r.La,
Password: r.Pa,
Expand Down
4 changes: 2 additions & 2 deletions app/resources/server/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func TransformQueryResult(s sampquery.Server, err error) (r All) {
r.Core = Essential{
IP: s.Address,
Hostname: s.Hostname,
Players: s.Players,
MaxPlayers: s.MaxPlayers,
Players: int64(s.Players),
MaxPlayers: int64(s.MaxPlayers),
Gamemode: s.Gamemode,
Language: s.Language,
Password: s.Password,
Expand Down

0 comments on commit fa9c5c5

Please sign in to comment.