2020-05-30 08:35:45 +00:00
|
|
|
package models
|
|
|
|
|
2020-06-18 12:51:31 +00:00
|
|
|
type Observation struct {
|
2020-05-30 08:35:45 +00:00
|
|
|
ID int `json:"id" gqlgen:"id"`
|
|
|
|
World string `pg:"unique:group_1" json:"world" gqlgen:"world"`
|
2020-06-18 13:54:31 +00:00
|
|
|
TribeID int `pg:"unique:group_1" json:"tribeID" gqlgen:"tribeID"`
|
2020-05-30 08:35:45 +00:00
|
|
|
ServerID string `pg:"on_delete:CASCADE,unique:group_1" json:"serverID" gqlgen:"serverID"`
|
|
|
|
Server *Server `json:"server,omitempty" gqlgen:"server"`
|
|
|
|
}
|
|
|
|
|
2020-06-18 12:51:31 +00:00
|
|
|
type Observations []*Observation
|
2020-05-30 10:43:11 +00:00
|
|
|
|
2020-06-18 12:51:31 +00:00
|
|
|
func (o Observations) Contains(world string, id int) bool {
|
|
|
|
for _, observation := range o {
|
|
|
|
if observation.TribeID == id && observation.World == world {
|
2020-05-30 10:43:11 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-06-18 12:51:31 +00:00
|
|
|
type ObservationFilter struct {
|
2020-05-30 08:54:28 +00:00
|
|
|
ID []int
|
2020-06-18 12:51:31 +00:00
|
|
|
World []string
|
2020-05-30 08:54:28 +00:00
|
|
|
ServerID []string
|
|
|
|
Limit int `urlstruct:",nowhere"`
|
|
|
|
Offset int `urlstruct:",nowhere"`
|
|
|
|
Order []string `urlstruct:",nowhere"`
|
2020-05-30 08:35:45 +00:00
|
|
|
}
|