update ServerStats, PlayerHistory, TribeHistory model

This commit is contained in:
Dawid Wysokiński 2020-06-25 15:10:45 +02:00
parent 6d18ee3346
commit 74c5a9b3b4
3 changed files with 5 additions and 5 deletions

View File

@ -7,14 +7,14 @@ type PlayerHistory struct {
OpponentsDefeated
PlayerID int `json:"playerID" gqlgen:"playerID" xml:"playerID"`
PlayerID int `pg:",unique:group_1" json:"playerID" gqlgen:"playerID" xml:"playerID"`
Player *Player `json:"player" gqlgen:"-" xml:"player"`
TotalVillages int `json:"totalVillages" pg:",use_zero" gqlgen:"totalVillages" xml:"totalVillages"`
Points int `json:"points" pg:",use_zero" gqlgen:"points" xml:"points"`
Rank int `json:"rank" pg:",use_zero" gqlgen:"rank" xml:"rank"`
TribeID int `json:"-" pg:",use_zero" gqlgen:"tribeID" xml:"tribeID"`
Tribe *Tribe `json:"tribe,omitempty" gqlgen:"-" xml:"tribe"`
CreatedAt time.Time `pg:"default:now(),use_zero" json:"createdAt" gqlgen:"createdAt" xml:"createdAt"`
CreatedAt time.Time `pg:"default:now(),type:DATE,unique:group_1,use_zero" json:"createdAt" gqlgen:"createdAt" xml:"createdAt"`
}
type PlayerHistoryFilter struct {

View File

@ -18,7 +18,7 @@ type ServerStats struct {
BonusVillages int `pg:",use_zero" json:"bonusVillages" gqlgen:"bonusVillages" xml:"bonusVillages"`
BarbarianVillages int `pg:",use_zero" json:"barbarianVillages" gqlgen:"barbarianVillages" xml:"barbarianVillages"`
PlayerVillages int `pg:",use_zero" json:"playerVillages" gqlgen:"playerVillages" xml:"playerVillages"`
CreatedAt time.Time `pg:"default:now(),use_zero" json:"createdAt" gqlgen:"createdAt" xml:"createdAt"`
CreatedAt time.Time `pg:"default:now(),type:DATE,unique:group_1,use_zero" json:"createdAt" gqlgen:"createdAt" xml:"createdAt"`
}
func (s *ServerStats) BeforeInsert(ctx context.Context) (context.Context, error) {

View File

@ -7,7 +7,7 @@ type TribeHistory struct {
OpponentsDefeated
TribeID int `json:"-" pg:",use_zero" gqlgen:"tribeID" xml:"tribeID"`
TribeID int `pg:",unique:group_1" json:"-" pg:",use_zero" gqlgen:"tribeID" xml:"tribeID"`
Tribe *Tribe `json:"tribe,omitempty" gqlgen:"-" xml:"tribe"`
TotalMembers int `json:"totalMembers" gqlgen:"totalMembers" pg:",use_zero"`
TotalVillages int `json:"totalVillages" gqlgen:"totalVillages" pg:",use_zero"`
@ -15,7 +15,7 @@ type TribeHistory struct {
AllPoints int `json:"allPoints" gqlgen:"allPoints" pg:",use_zero"`
Rank int `json:"rank" gqlgen:"rank" pg:",use_zero"`
Dominance float64 `json:"dominance" gqlgen:"dominance" pg:",use_zero"`
CreatedAt time.Time `pg:"default:now(),use_zero" json:"createdAt" gqlgen:"createdAt" xml:"createdAt"`
CreatedAt time.Time `pg:"default:now(),type:DATE,unique:group_1,use_zero" json:"createdAt" gqlgen:"createdAt" xml:"createdAt"`
}
type TribeHistoryFilter struct {