fill history if an older match appeared
This commit is contained in:
125
ent/mutation.go
125
ent/mutation.go
@@ -1205,31 +1205,32 @@ func (m *MatchMutation) ResetEdge(name string) error {
|
||||
// PlayerMutation represents an operation that mutates the Player nodes in the graph.
|
||||
type PlayerMutation struct {
|
||||
config
|
||||
op Op
|
||||
typ string
|
||||
id *uint64
|
||||
name *string
|
||||
avatar *string
|
||||
vanity_url *string
|
||||
vanity_url_real *string
|
||||
vac *bool
|
||||
vac_date *time.Time
|
||||
vac_count *int
|
||||
addvac_count *int
|
||||
steam_updated *time.Time
|
||||
sharecode_updated *time.Time
|
||||
auth_code *string
|
||||
profile_created *time.Time
|
||||
clearedFields map[string]struct{}
|
||||
stats map[int]struct{}
|
||||
removedstats map[int]struct{}
|
||||
clearedstats bool
|
||||
matches map[uint64]struct{}
|
||||
removedmatches map[uint64]struct{}
|
||||
clearedmatches bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Player, error)
|
||||
predicates []predicate.Player
|
||||
op Op
|
||||
typ string
|
||||
id *uint64
|
||||
name *string
|
||||
avatar *string
|
||||
vanity_url *string
|
||||
vanity_url_real *string
|
||||
vac *bool
|
||||
vac_date *time.Time
|
||||
vac_count *int
|
||||
addvac_count *int
|
||||
steam_updated *time.Time
|
||||
sharecode_updated *time.Time
|
||||
auth_code *string
|
||||
profile_created *time.Time
|
||||
oldest_sharecode_seen *string
|
||||
clearedFields map[string]struct{}
|
||||
stats map[int]struct{}
|
||||
removedstats map[int]struct{}
|
||||
clearedstats bool
|
||||
matches map[uint64]struct{}
|
||||
removedmatches map[uint64]struct{}
|
||||
clearedmatches bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Player, error)
|
||||
predicates []predicate.Player
|
||||
}
|
||||
|
||||
var _ ent.Mutation = (*PlayerMutation)(nil)
|
||||
@@ -1851,6 +1852,55 @@ func (m *PlayerMutation) ResetProfileCreated() {
|
||||
delete(m.clearedFields, player.FieldProfileCreated)
|
||||
}
|
||||
|
||||
// SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field.
|
||||
func (m *PlayerMutation) SetOldestSharecodeSeen(s string) {
|
||||
m.oldest_sharecode_seen = &s
|
||||
}
|
||||
|
||||
// OldestSharecodeSeen returns the value of the "oldest_sharecode_seen" field in the mutation.
|
||||
func (m *PlayerMutation) OldestSharecodeSeen() (r string, exists bool) {
|
||||
v := m.oldest_sharecode_seen
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldOldestSharecodeSeen returns the old "oldest_sharecode_seen" field's value of the Player entity.
|
||||
// If the Player object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *PlayerMutation) OldOldestSharecodeSeen(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldOldestSharecodeSeen is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldOldestSharecodeSeen requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldOldestSharecodeSeen: %w", err)
|
||||
}
|
||||
return oldValue.OldestSharecodeSeen, nil
|
||||
}
|
||||
|
||||
// ClearOldestSharecodeSeen clears the value of the "oldest_sharecode_seen" field.
|
||||
func (m *PlayerMutation) ClearOldestSharecodeSeen() {
|
||||
m.oldest_sharecode_seen = nil
|
||||
m.clearedFields[player.FieldOldestSharecodeSeen] = struct{}{}
|
||||
}
|
||||
|
||||
// OldestSharecodeSeenCleared returns if the "oldest_sharecode_seen" field was cleared in this mutation.
|
||||
func (m *PlayerMutation) OldestSharecodeSeenCleared() bool {
|
||||
_, ok := m.clearedFields[player.FieldOldestSharecodeSeen]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetOldestSharecodeSeen resets all changes to the "oldest_sharecode_seen" field.
|
||||
func (m *PlayerMutation) ResetOldestSharecodeSeen() {
|
||||
m.oldest_sharecode_seen = nil
|
||||
delete(m.clearedFields, player.FieldOldestSharecodeSeen)
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the Stats entity by ids.
|
||||
func (m *PlayerMutation) AddStatIDs(ids ...int) {
|
||||
if m.stats == nil {
|
||||
@@ -1978,7 +2028,7 @@ func (m *PlayerMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *PlayerMutation) Fields() []string {
|
||||
fields := make([]string, 0, 11)
|
||||
fields := make([]string, 0, 12)
|
||||
if m.name != nil {
|
||||
fields = append(fields, player.FieldName)
|
||||
}
|
||||
@@ -2012,6 +2062,9 @@ func (m *PlayerMutation) Fields() []string {
|
||||
if m.profile_created != nil {
|
||||
fields = append(fields, player.FieldProfileCreated)
|
||||
}
|
||||
if m.oldest_sharecode_seen != nil {
|
||||
fields = append(fields, player.FieldOldestSharecodeSeen)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -2042,6 +2095,8 @@ func (m *PlayerMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.AuthCode()
|
||||
case player.FieldProfileCreated:
|
||||
return m.ProfileCreated()
|
||||
case player.FieldOldestSharecodeSeen:
|
||||
return m.OldestSharecodeSeen()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -2073,6 +2128,8 @@ func (m *PlayerMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
return m.OldAuthCode(ctx)
|
||||
case player.FieldProfileCreated:
|
||||
return m.OldProfileCreated(ctx)
|
||||
case player.FieldOldestSharecodeSeen:
|
||||
return m.OldOldestSharecodeSeen(ctx)
|
||||
}
|
||||
return nil, fmt.Errorf("unknown Player field %s", name)
|
||||
}
|
||||
@@ -2159,6 +2216,13 @@ func (m *PlayerMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetProfileCreated(v)
|
||||
return nil
|
||||
case player.FieldOldestSharecodeSeen:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetOldestSharecodeSeen(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Player field %s", name)
|
||||
}
|
||||
@@ -2231,6 +2295,9 @@ func (m *PlayerMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(player.FieldProfileCreated) {
|
||||
fields = append(fields, player.FieldProfileCreated)
|
||||
}
|
||||
if m.FieldCleared(player.FieldOldestSharecodeSeen) {
|
||||
fields = append(fields, player.FieldOldestSharecodeSeen)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
@@ -2272,6 +2339,9 @@ func (m *PlayerMutation) ClearField(name string) error {
|
||||
case player.FieldProfileCreated:
|
||||
m.ClearProfileCreated()
|
||||
return nil
|
||||
case player.FieldOldestSharecodeSeen:
|
||||
m.ClearOldestSharecodeSeen()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Player nullable field %s", name)
|
||||
}
|
||||
@@ -2313,6 +2383,9 @@ func (m *PlayerMutation) ResetField(name string) error {
|
||||
case player.FieldProfileCreated:
|
||||
m.ResetProfileCreated()
|
||||
return nil
|
||||
case player.FieldOldestSharecodeSeen:
|
||||
m.ResetOldestSharecodeSeen()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Player field %s", name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user