import from unified repo

This commit is contained in:
2021-10-03 16:24:20 +02:00
commit 79d1df4cf3
50 changed files with 21269 additions and 0 deletions

45
ent/schema/match.go Normal file
View File

@@ -0,0 +1,45 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Match holds the schema definition for the Match entity.
type Match struct {
ent.Schema
}
// Fields of the Match.
func (Match) Fields() []ent.Field {
return []ent.Field{
field.Uint64("match_id").Unique().Immutable().StructTag(`json:"match_id,string"`),
field.String("share_code"),
field.String("map").Optional(),
field.Time("date"),
field.Int("score_team_a"),
field.Int("score_team_b"),
field.String("replay_url").Optional().StructTag(`json:"-"`),
field.Int("duration"),
field.Int("match_result"),
field.Int("max_rounds"),
field.Bool("demo_expired").Default(false),
field.Bool("demo_parsed").Default(false),
field.JSON("eco", struct {
Rounds []*struct {
Team int `json:"team"`
Bank int `json:"bank"`
Equipment int `json:"equipment"`
} `json:"rounds"`
}{}).Optional(),
}
}
// Edges of the Match.
func (Match) Edges() []ent.Edge {
return []ent.Edge{
edge.To("stats", Stats.Type),
edge.From("players", Player.Type).Ref("matches"),
}
}

40
ent/schema/player.go Normal file
View File

@@ -0,0 +1,40 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"time"
)
// Player holds the schema definition for the Player entity.
type Player struct {
ent.Schema
}
// Fields of the Player.
func (Player) Fields() []ent.Field {
return []ent.Field{
field.Uint64("steamid").Unique().Immutable().StructTag(`json:",string"`),
field.String("name").Optional(),
field.String("avatar_url").Optional(),
field.String("vanity_url").Optional(),
field.String("vanity_url_real").Optional(),
field.Bool("vac").Default(false),
field.Time("vac_date").Optional(),
field.Int("vac_count").Optional(),
field.Time("steam_updated").Default(func() time.Time {
return time.Now().UTC()
}).StructTag(`json:"-"`),
field.Time("sharecode_updated").Optional().StructTag(`json:"-"`),
field.String("auth_code").Optional().Sensitive(),
}
}
// Edges of the Player.
func (Player) Edges() []ent.Edge {
return []ent.Edge{
edge.To("stats", Stats.Type),
edge.To("matches", Match.Type),
}
}

81
ent/schema/stats.go Normal file
View File

@@ -0,0 +1,81 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Stats holds the schema definition for the Stats entity.
type Stats struct {
ent.Schema
}
// Fields of the Stats.
func (Stats) Fields() []ent.Field {
return []ent.Field{
field.Int("team_id"),
field.Int("kills"),
field.Int("deaths"),
field.Int("assists"),
field.Int("headshot"),
field.Int("mvp"),
field.Int("score"),
field.JSON("extended", struct {
MultiKills struct {
Duo int `json:"duo,omitempty"`
Triple int `json:"triple,omitempty"`
Quad int `json:"quad,omitempty"`
Pent int `json:"pent,omitempty"`
} `json:"multi_kills,omitempty"`
Dmg struct {
Enemy int `json:"enemy,omitempty"`
Team int `json:"team,omitempty"`
UD struct {
HE int `json:"he,omitempty"`
Flames int `json:"flames,omitempty"`
Flash int `json:"flash,omitempty"`
Decoy int `json:"decoy,omitempty"`
Smoke int `json:"smoke,omitempty"`
} `json:"ud,omitempty"`
HitGroup struct {
Head int `json:"head,omitempty"`
Chest int `json:"chest,omitempty"`
Stomach int `json:"stomach,omitempty"`
LeftArm int `json:"left_arm,omitempty"`
RightArm int `json:"right_arm,omitempty"`
LeftLeg int `json:"left_leg,omitempty"`
RightLeg int `json:"right_leg,omitempty"`
Gear int `json:"gear,omitempty"`
} `json:"hit_group,omitempty"`
} `json:"dmg,omitempty"`
Crosshair string `json:"crosshair,omitempty"`
Color int `json:"color,omitempty"`
KAST int `json:"kast,omitempty"`
Rank struct {
Old int `json:"old,omitempty"`
New int `json:"new,omitempty"`
} `json:"rank,omitempty"`
Flash struct {
Duration struct {
Self float32 `json:"self,omitempty"`
Team float32 `json:"team,omitempty"`
Enemy float32 `json:"enemy,omitempty"`
} `json:"duration,omitempty"`
Total struct {
Team int `json:"team,omitempty"`
Enemy int `json:"enemy,omitempty"`
Self int `json:"self,omitempty"`
} `json:"total,omitempty"`
} `json:"flash,omitempty"`
}{}).Optional(),
}
}
// Edges of the Stats.
func (Stats) Edges() []ent.Edge {
return []ent.Edge{
edge.From("matches", Match.Type).Ref("stats").Unique(),
edge.From("players", Player.Type).Ref("stats").Unique(),
}
}