added tick to messages
This commit is contained in:
@@ -252,6 +252,7 @@ func (p *DemoParser) parseWorker() {
|
|||||||
|
|
||||||
// onChatMessage
|
// onChatMessage
|
||||||
demoParser.RegisterEventHandler(func(e events.ChatMessage) {
|
demoParser.RegisterEventHandler(func(e events.ChatMessage) {
|
||||||
|
gs := demoParser.GameState()
|
||||||
tAttacker, err := p.MatchPlayerBySteamID(tStats, e.Sender.SteamID64)
|
tAttacker, err := p.MatchPlayerBySteamID(tStats, e.Sender.SteamID64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("[DP] Unable to get player for id %d: %v", e.Sender.SteamID64, err)
|
log.Warningf("[DP] Unable to get player for id %d: %v", e.Sender.SteamID64, err)
|
||||||
@@ -261,6 +262,7 @@ func (p *DemoParser) parseWorker() {
|
|||||||
tAttacker.Edges.Messages = append(tAttacker.Edges.Messages, &ent.Messages{
|
tAttacker.Edges.Messages = append(tAttacker.Edges.Messages, &ent.Messages{
|
||||||
Message: e.Text,
|
Message: e.Text,
|
||||||
AllChat: e.IsChatAll,
|
AllChat: e.IsChatAll,
|
||||||
|
Tick: gs.IngameTick(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -513,7 +515,7 @@ func (p *DemoParser) parseWorker() {
|
|||||||
|
|
||||||
bulk := make([]*ent.MessagesCreate, 0)
|
bulk := make([]*ent.MessagesCreate, 0)
|
||||||
for _, msg := range tMatchPlayer.Edges.Messages {
|
for _, msg := range tMatchPlayer.Edges.Messages {
|
||||||
bulk = append(bulk, p.db.Messages.Create().SetMessage(msg.Message).SetAllChat(msg.AllChat).SetMatchPlayer(tMatchPlayer))
|
bulk = append(bulk, p.db.Messages.Create().SetMessage(msg.Message).SetAllChat(msg.AllChat).SetTick(msg.Tick).SetMatchPlayer(tMatchPlayer))
|
||||||
}
|
}
|
||||||
if len(bulk) > 0 {
|
if len(bulk) > 0 {
|
||||||
err = p.db.Messages.CreateBulk(bulk...).Exec(context.Background())
|
err = p.db.Messages.CreateBulk(bulk...).Exec(context.Background())
|
||||||
|
@@ -20,6 +20,8 @@ type Messages struct {
|
|||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
// AllChat holds the value of the "all_chat" field.
|
// AllChat holds the value of the "all_chat" field.
|
||||||
AllChat bool `json:"all_chat,omitempty"`
|
AllChat bool `json:"all_chat,omitempty"`
|
||||||
|
// Tick holds the value of the "tick" field.
|
||||||
|
Tick int `json:"tick,omitempty"`
|
||||||
// Edges holds the relations/edges for other nodes in the graph.
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
// The values are being populated by the MessagesQuery when eager-loading is set.
|
// The values are being populated by the MessagesQuery when eager-loading is set.
|
||||||
Edges MessagesEdges `json:"edges"`
|
Edges MessagesEdges `json:"edges"`
|
||||||
@@ -56,7 +58,7 @@ func (*Messages) scanValues(columns []string) ([]interface{}, error) {
|
|||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case messages.FieldAllChat:
|
case messages.FieldAllChat:
|
||||||
values[i] = new(sql.NullBool)
|
values[i] = new(sql.NullBool)
|
||||||
case messages.FieldID:
|
case messages.FieldID, messages.FieldTick:
|
||||||
values[i] = new(sql.NullInt64)
|
values[i] = new(sql.NullInt64)
|
||||||
case messages.FieldMessage:
|
case messages.FieldMessage:
|
||||||
values[i] = new(sql.NullString)
|
values[i] = new(sql.NullString)
|
||||||
@@ -95,6 +97,12 @@ func (m *Messages) assignValues(columns []string, values []interface{}) error {
|
|||||||
} else if value.Valid {
|
} else if value.Valid {
|
||||||
m.AllChat = value.Bool
|
m.AllChat = value.Bool
|
||||||
}
|
}
|
||||||
|
case messages.FieldTick:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field tick", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
m.Tick = int(value.Int64)
|
||||||
|
}
|
||||||
case messages.ForeignKeys[0]:
|
case messages.ForeignKeys[0]:
|
||||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for edge-field match_player_messages", value)
|
return fmt.Errorf("unexpected type %T for edge-field match_player_messages", value)
|
||||||
@@ -139,6 +147,8 @@ func (m *Messages) String() string {
|
|||||||
builder.WriteString(m.Message)
|
builder.WriteString(m.Message)
|
||||||
builder.WriteString(", all_chat=")
|
builder.WriteString(", all_chat=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", m.AllChat))
|
builder.WriteString(fmt.Sprintf("%v", m.AllChat))
|
||||||
|
builder.WriteString(", tick=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", m.Tick))
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
return builder.String()
|
return builder.String()
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,8 @@ const (
|
|||||||
FieldMessage = "message"
|
FieldMessage = "message"
|
||||||
// FieldAllChat holds the string denoting the all_chat field in the database.
|
// FieldAllChat holds the string denoting the all_chat field in the database.
|
||||||
FieldAllChat = "all_chat"
|
FieldAllChat = "all_chat"
|
||||||
|
// FieldTick holds the string denoting the tick field in the database.
|
||||||
|
FieldTick = "tick"
|
||||||
// EdgeMatchPlayer holds the string denoting the match_player edge name in mutations.
|
// EdgeMatchPlayer holds the string denoting the match_player edge name in mutations.
|
||||||
EdgeMatchPlayer = "match_player"
|
EdgeMatchPlayer = "match_player"
|
||||||
// Table holds the table name of the messages in the database.
|
// Table holds the table name of the messages in the database.
|
||||||
@@ -29,6 +31,7 @@ var Columns = []string{
|
|||||||
FieldID,
|
FieldID,
|
||||||
FieldMessage,
|
FieldMessage,
|
||||||
FieldAllChat,
|
FieldAllChat,
|
||||||
|
FieldTick,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "messages"
|
// ForeignKeys holds the SQL foreign-keys that are owned by the "messages"
|
||||||
|
@@ -106,6 +106,13 @@ func AllChat(v bool) predicate.Messages {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tick applies equality check predicate on the "tick" field. It's identical to TickEQ.
|
||||||
|
func Tick(v int) predicate.Messages {
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldTick), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// MessageEQ applies the EQ predicate on the "message" field.
|
// MessageEQ applies the EQ predicate on the "message" field.
|
||||||
func MessageEQ(v string) predicate.Messages {
|
func MessageEQ(v string) predicate.Messages {
|
||||||
return predicate.Messages(func(s *sql.Selector) {
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
@@ -231,6 +238,82 @@ func AllChatNEQ(v bool) predicate.Messages {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TickEQ applies the EQ predicate on the "tick" field.
|
||||||
|
func TickEQ(v int) predicate.Messages {
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.EQ(s.C(FieldTick), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TickNEQ applies the NEQ predicate on the "tick" field.
|
||||||
|
func TickNEQ(v int) predicate.Messages {
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.NEQ(s.C(FieldTick), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TickIn applies the In predicate on the "tick" field.
|
||||||
|
func TickIn(vs ...int) predicate.Messages {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
// if not arguments were provided, append the FALSE constants,
|
||||||
|
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||||
|
if len(v) == 0 {
|
||||||
|
s.Where(sql.False())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.Where(sql.In(s.C(FieldTick), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TickNotIn applies the NotIn predicate on the "tick" field.
|
||||||
|
func TickNotIn(vs ...int) predicate.Messages {
|
||||||
|
v := make([]interface{}, len(vs))
|
||||||
|
for i := range v {
|
||||||
|
v[i] = vs[i]
|
||||||
|
}
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
// if not arguments were provided, append the FALSE constants,
|
||||||
|
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||||
|
if len(v) == 0 {
|
||||||
|
s.Where(sql.False())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.Where(sql.NotIn(s.C(FieldTick), v...))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TickGT applies the GT predicate on the "tick" field.
|
||||||
|
func TickGT(v int) predicate.Messages {
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GT(s.C(FieldTick), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TickGTE applies the GTE predicate on the "tick" field.
|
||||||
|
func TickGTE(v int) predicate.Messages {
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.GTE(s.C(FieldTick), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TickLT applies the LT predicate on the "tick" field.
|
||||||
|
func TickLT(v int) predicate.Messages {
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LT(s.C(FieldTick), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// TickLTE applies the LTE predicate on the "tick" field.
|
||||||
|
func TickLTE(v int) predicate.Messages {
|
||||||
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.LTE(s.C(FieldTick), v))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// HasMatchPlayer applies the HasEdge predicate on the "match_player" edge.
|
// HasMatchPlayer applies the HasEdge predicate on the "match_player" edge.
|
||||||
func HasMatchPlayer() predicate.Messages {
|
func HasMatchPlayer() predicate.Messages {
|
||||||
return predicate.Messages(func(s *sql.Selector) {
|
return predicate.Messages(func(s *sql.Selector) {
|
||||||
|
@@ -32,6 +32,12 @@ func (mc *MessagesCreate) SetAllChat(b bool) *MessagesCreate {
|
|||||||
return mc
|
return mc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTick sets the "tick" field.
|
||||||
|
func (mc *MessagesCreate) SetTick(i int) *MessagesCreate {
|
||||||
|
mc.mutation.SetTick(i)
|
||||||
|
return mc
|
||||||
|
}
|
||||||
|
|
||||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||||
func (mc *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate {
|
func (mc *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate {
|
||||||
mc.mutation.SetMatchPlayerID(id)
|
mc.mutation.SetMatchPlayerID(id)
|
||||||
@@ -127,6 +133,9 @@ func (mc *MessagesCreate) check() error {
|
|||||||
if _, ok := mc.mutation.AllChat(); !ok {
|
if _, ok := mc.mutation.AllChat(); !ok {
|
||||||
return &ValidationError{Name: "all_chat", err: errors.New(`ent: missing required field "Messages.all_chat"`)}
|
return &ValidationError{Name: "all_chat", err: errors.New(`ent: missing required field "Messages.all_chat"`)}
|
||||||
}
|
}
|
||||||
|
if _, ok := mc.mutation.Tick(); !ok {
|
||||||
|
return &ValidationError{Name: "tick", err: errors.New(`ent: missing required field "Messages.tick"`)}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +179,14 @@ func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
|
|||||||
})
|
})
|
||||||
_node.AllChat = value
|
_node.AllChat = value
|
||||||
}
|
}
|
||||||
|
if value, ok := mc.mutation.Tick(); ok {
|
||||||
|
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Value: value,
|
||||||
|
Column: messages.FieldTick,
|
||||||
|
})
|
||||||
|
_node.Tick = value
|
||||||
|
}
|
||||||
if nodes := mc.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
if nodes := mc.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
|
@@ -40,6 +40,19 @@ func (mu *MessagesUpdate) SetAllChat(b bool) *MessagesUpdate {
|
|||||||
return mu
|
return mu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTick sets the "tick" field.
|
||||||
|
func (mu *MessagesUpdate) SetTick(i int) *MessagesUpdate {
|
||||||
|
mu.mutation.ResetTick()
|
||||||
|
mu.mutation.SetTick(i)
|
||||||
|
return mu
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTick adds i to the "tick" field.
|
||||||
|
func (mu *MessagesUpdate) AddTick(i int) *MessagesUpdate {
|
||||||
|
mu.mutation.AddTick(i)
|
||||||
|
return mu
|
||||||
|
}
|
||||||
|
|
||||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||||
func (mu *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate {
|
func (mu *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate {
|
||||||
mu.mutation.SetMatchPlayerID(id)
|
mu.mutation.SetMatchPlayerID(id)
|
||||||
@@ -156,6 +169,20 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||||||
Column: messages.FieldAllChat,
|
Column: messages.FieldAllChat,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if value, ok := mu.mutation.Tick(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Value: value,
|
||||||
|
Column: messages.FieldTick,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := mu.mutation.AddedTick(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Value: value,
|
||||||
|
Column: messages.FieldTick,
|
||||||
|
})
|
||||||
|
}
|
||||||
if mu.mutation.MatchPlayerCleared() {
|
if mu.mutation.MatchPlayerCleared() {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
@@ -222,6 +249,19 @@ func (muo *MessagesUpdateOne) SetAllChat(b bool) *MessagesUpdateOne {
|
|||||||
return muo
|
return muo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTick sets the "tick" field.
|
||||||
|
func (muo *MessagesUpdateOne) SetTick(i int) *MessagesUpdateOne {
|
||||||
|
muo.mutation.ResetTick()
|
||||||
|
muo.mutation.SetTick(i)
|
||||||
|
return muo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTick adds i to the "tick" field.
|
||||||
|
func (muo *MessagesUpdateOne) AddTick(i int) *MessagesUpdateOne {
|
||||||
|
muo.mutation.AddTick(i)
|
||||||
|
return muo
|
||||||
|
}
|
||||||
|
|
||||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||||
func (muo *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne {
|
func (muo *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne {
|
||||||
muo.mutation.SetMatchPlayerID(id)
|
muo.mutation.SetMatchPlayerID(id)
|
||||||
@@ -362,6 +402,20 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
|
|||||||
Column: messages.FieldAllChat,
|
Column: messages.FieldAllChat,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if value, ok := muo.mutation.Tick(); ok {
|
||||||
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Value: value,
|
||||||
|
Column: messages.FieldTick,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if value, ok := muo.mutation.AddedTick(); ok {
|
||||||
|
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeInt,
|
||||||
|
Value: value,
|
||||||
|
Column: messages.FieldTick,
|
||||||
|
})
|
||||||
|
}
|
||||||
if muo.mutation.MatchPlayerCleared() {
|
if muo.mutation.MatchPlayerCleared() {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
|
@@ -92,6 +92,7 @@ var (
|
|||||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
{Name: "message", Type: field.TypeString, Size: 2147483647},
|
{Name: "message", Type: field.TypeString, Size: 2147483647},
|
||||||
{Name: "all_chat", Type: field.TypeBool},
|
{Name: "all_chat", Type: field.TypeBool},
|
||||||
|
{Name: "tick", Type: field.TypeInt},
|
||||||
{Name: "match_player_messages", Type: field.TypeInt, Nullable: true},
|
{Name: "match_player_messages", Type: field.TypeInt, Nullable: true},
|
||||||
}
|
}
|
||||||
// MessagesTable holds the schema information for the "messages" table.
|
// MessagesTable holds the schema information for the "messages" table.
|
||||||
@@ -102,7 +103,7 @@ var (
|
|||||||
ForeignKeys: []*schema.ForeignKey{
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
{
|
{
|
||||||
Symbol: "messages_match_players_messages",
|
Symbol: "messages_match_players_messages",
|
||||||
Columns: []*schema.Column{MessagesColumns[3]},
|
Columns: []*schema.Column{MessagesColumns[4]},
|
||||||
RefColumns: []*schema.Column{MatchPlayersColumns[0]},
|
RefColumns: []*schema.Column{MatchPlayersColumns[0]},
|
||||||
OnDelete: schema.SetNull,
|
OnDelete: schema.SetNull,
|
||||||
},
|
},
|
||||||
|
@@ -5284,6 +5284,8 @@ type MessagesMutation struct {
|
|||||||
id *int
|
id *int
|
||||||
message *string
|
message *string
|
||||||
all_chat *bool
|
all_chat *bool
|
||||||
|
tick *int
|
||||||
|
addtick *int
|
||||||
clearedFields map[string]struct{}
|
clearedFields map[string]struct{}
|
||||||
match_player *int
|
match_player *int
|
||||||
clearedmatch_player bool
|
clearedmatch_player bool
|
||||||
@@ -5462,6 +5464,62 @@ func (m *MessagesMutation) ResetAllChat() {
|
|||||||
m.all_chat = nil
|
m.all_chat = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTick sets the "tick" field.
|
||||||
|
func (m *MessagesMutation) SetTick(i int) {
|
||||||
|
m.tick = &i
|
||||||
|
m.addtick = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tick returns the value of the "tick" field in the mutation.
|
||||||
|
func (m *MessagesMutation) Tick() (r int, exists bool) {
|
||||||
|
v := m.tick
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// OldTick returns the old "tick" field's value of the Messages entity.
|
||||||
|
// If the Messages 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 *MessagesMutation) OldTick(ctx context.Context) (v int, err error) {
|
||||||
|
if !m.op.Is(OpUpdateOne) {
|
||||||
|
return v, errors.New("OldTick is only allowed on UpdateOne operations")
|
||||||
|
}
|
||||||
|
if m.id == nil || m.oldValue == nil {
|
||||||
|
return v, errors.New("OldTick requires an ID field in the mutation")
|
||||||
|
}
|
||||||
|
oldValue, err := m.oldValue(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return v, fmt.Errorf("querying old value for OldTick: %w", err)
|
||||||
|
}
|
||||||
|
return oldValue.Tick, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTick adds i to the "tick" field.
|
||||||
|
func (m *MessagesMutation) AddTick(i int) {
|
||||||
|
if m.addtick != nil {
|
||||||
|
*m.addtick += i
|
||||||
|
} else {
|
||||||
|
m.addtick = &i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddedTick returns the value that was added to the "tick" field in this mutation.
|
||||||
|
func (m *MessagesMutation) AddedTick() (r int, exists bool) {
|
||||||
|
v := m.addtick
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetTick resets all changes to the "tick" field.
|
||||||
|
func (m *MessagesMutation) ResetTick() {
|
||||||
|
m.tick = nil
|
||||||
|
m.addtick = nil
|
||||||
|
}
|
||||||
|
|
||||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by id.
|
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by id.
|
||||||
func (m *MessagesMutation) SetMatchPlayerID(id int) {
|
func (m *MessagesMutation) SetMatchPlayerID(id int) {
|
||||||
m.match_player = &id
|
m.match_player = &id
|
||||||
@@ -5520,13 +5578,16 @@ func (m *MessagesMutation) Type() string {
|
|||||||
// order to get all numeric fields that were incremented/decremented, call
|
// order to get all numeric fields that were incremented/decremented, call
|
||||||
// AddedFields().
|
// AddedFields().
|
||||||
func (m *MessagesMutation) Fields() []string {
|
func (m *MessagesMutation) Fields() []string {
|
||||||
fields := make([]string, 0, 2)
|
fields := make([]string, 0, 3)
|
||||||
if m.message != nil {
|
if m.message != nil {
|
||||||
fields = append(fields, messages.FieldMessage)
|
fields = append(fields, messages.FieldMessage)
|
||||||
}
|
}
|
||||||
if m.all_chat != nil {
|
if m.all_chat != nil {
|
||||||
fields = append(fields, messages.FieldAllChat)
|
fields = append(fields, messages.FieldAllChat)
|
||||||
}
|
}
|
||||||
|
if m.tick != nil {
|
||||||
|
fields = append(fields, messages.FieldTick)
|
||||||
|
}
|
||||||
return fields
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5539,6 +5600,8 @@ func (m *MessagesMutation) Field(name string) (ent.Value, bool) {
|
|||||||
return m.Message()
|
return m.Message()
|
||||||
case messages.FieldAllChat:
|
case messages.FieldAllChat:
|
||||||
return m.AllChat()
|
return m.AllChat()
|
||||||
|
case messages.FieldTick:
|
||||||
|
return m.Tick()
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@@ -5552,6 +5615,8 @@ func (m *MessagesMutation) OldField(ctx context.Context, name string) (ent.Value
|
|||||||
return m.OldMessage(ctx)
|
return m.OldMessage(ctx)
|
||||||
case messages.FieldAllChat:
|
case messages.FieldAllChat:
|
||||||
return m.OldAllChat(ctx)
|
return m.OldAllChat(ctx)
|
||||||
|
case messages.FieldTick:
|
||||||
|
return m.OldTick(ctx)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("unknown Messages field %s", name)
|
return nil, fmt.Errorf("unknown Messages field %s", name)
|
||||||
}
|
}
|
||||||
@@ -5575,6 +5640,13 @@ func (m *MessagesMutation) SetField(name string, value ent.Value) error {
|
|||||||
}
|
}
|
||||||
m.SetAllChat(v)
|
m.SetAllChat(v)
|
||||||
return nil
|
return nil
|
||||||
|
case messages.FieldTick:
|
||||||
|
v, ok := value.(int)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.SetTick(v)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Messages field %s", name)
|
return fmt.Errorf("unknown Messages field %s", name)
|
||||||
}
|
}
|
||||||
@@ -5582,13 +5654,21 @@ func (m *MessagesMutation) SetField(name string, value ent.Value) error {
|
|||||||
// AddedFields returns all numeric fields that were incremented/decremented during
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
||||||
// this mutation.
|
// this mutation.
|
||||||
func (m *MessagesMutation) AddedFields() []string {
|
func (m *MessagesMutation) AddedFields() []string {
|
||||||
return nil
|
var fields []string
|
||||||
|
if m.addtick != nil {
|
||||||
|
fields = append(fields, messages.FieldTick)
|
||||||
|
}
|
||||||
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddedField returns the numeric value that was incremented/decremented on a field
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
||||||
// with the given name. The second boolean return value indicates that this field
|
// with the given name. The second boolean return value indicates that this field
|
||||||
// was not set, or was not defined in the schema.
|
// was not set, or was not defined in the schema.
|
||||||
func (m *MessagesMutation) AddedField(name string) (ent.Value, bool) {
|
func (m *MessagesMutation) AddedField(name string) (ent.Value, bool) {
|
||||||
|
switch name {
|
||||||
|
case messages.FieldTick:
|
||||||
|
return m.AddedTick()
|
||||||
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5597,6 +5677,13 @@ func (m *MessagesMutation) AddedField(name string) (ent.Value, bool) {
|
|||||||
// type.
|
// type.
|
||||||
func (m *MessagesMutation) AddField(name string, value ent.Value) error {
|
func (m *MessagesMutation) AddField(name string, value ent.Value) error {
|
||||||
switch name {
|
switch name {
|
||||||
|
case messages.FieldTick:
|
||||||
|
v, ok := value.(int)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.AddTick(v)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Messages numeric field %s", name)
|
return fmt.Errorf("unknown Messages numeric field %s", name)
|
||||||
}
|
}
|
||||||
@@ -5630,6 +5717,9 @@ func (m *MessagesMutation) ResetField(name string) error {
|
|||||||
case messages.FieldAllChat:
|
case messages.FieldAllChat:
|
||||||
m.ResetAllChat()
|
m.ResetAllChat()
|
||||||
return nil
|
return nil
|
||||||
|
case messages.FieldTick:
|
||||||
|
m.ResetTick()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Messages field %s", name)
|
return fmt.Errorf("unknown Messages field %s", name)
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ func (Messages) Fields() []ent.Field {
|
|||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.Text("message"),
|
field.Text("message"),
|
||||||
field.Bool("all_chat"),
|
field.Bool("all_chat"),
|
||||||
|
field.Int("tick"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
go.sum
5
go.sum
@@ -302,6 +302,7 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
|
|||||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
|
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||||
@@ -332,6 +333,7 @@ github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+
|
|||||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||||
|
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
@@ -410,8 +412,10 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
|
|||||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
||||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||||
|
github.com/spf13/cobra v1.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0=
|
||||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||||
@@ -620,6 +624,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
|
|||||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||||
|
golang.org/x/tools v0.1.9-0.20211216111533-8d383106f7e7 h1:M1gcVrIb2lSn2FIL19DG0+/b8nNVKJ7W7b4WcAGZAYM=
|
||||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
Reference in New Issue
Block a user