Use UUIDs for AskedQuestions as well
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/facebook/ent"
|
"github.com/facebook/ent"
|
||||||
"github.com/facebook/ent/schema/edge"
|
"github.com/facebook/ent/schema/edge"
|
||||||
"github.com/facebook/ent/schema/field"
|
"github.com/facebook/ent/schema/field"
|
||||||
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AskedQuestion struct {
|
type AskedQuestion struct {
|
||||||
@@ -12,6 +13,7 @@ type AskedQuestion struct {
|
|||||||
|
|
||||||
func (AskedQuestion) Fields() []ent.Field {
|
func (AskedQuestion) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
|
field.UUID("id", uuid.New()).Immutable(),
|
||||||
field.Time("asked").Immutable(),
|
field.Time("asked").Immutable(),
|
||||||
field.Time("ended"),
|
field.Time("ended"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ func (m *Model) NextQuestion(sessionId uuid.UUID, c context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if next, err := query.First(c); err == nil {
|
if next, err := query.First(c); err == nil {
|
||||||
if _, err := tx.AskedQuestion.Create().SetAsked(now).SetSessionID(sessionId).SetQuestion(next).SetEnded(now.Add(time.Duration(int64(next.DefaultLength)) * time.Millisecond)).Save(c); err != nil {
|
if _, err := tx.AskedQuestion.Create().SetID(uuid.New()).SetAsked(now).SetSessionID(sessionId).SetQuestion(next).SetEnded(now.Add(time.Duration(int64(next.DefaultLength)) * time.Millisecond)).Save(c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if ent.IsNotFound(err) {
|
} else if ent.IsNotFound(err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user