Implement switching to next question
This commit is contained in:
41
pkg/model/ent/schema/askedQuestion.go
Normal file
41
pkg/model/ent/schema/askedQuestion.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/schema/edge"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
|
||||
type AskedQuestion struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (AskedQuestion) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Time("asked").Immutable(),
|
||||
field.Time("ended"),
|
||||
}
|
||||
}
|
||||
|
||||
func (AskedQuestion) Indexes() []ent.Index {
|
||||
return []ent.Index{}
|
||||
}
|
||||
|
||||
func (AskedQuestion) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("session", Session.Type).
|
||||
Ref("askedQuestions").
|
||||
Unique().
|
||||
Required(),
|
||||
edge.From("question", Question.Type).
|
||||
Ref("asked").
|
||||
Unique().
|
||||
Required(),
|
||||
}
|
||||
}
|
||||
|
||||
func (AskedQuestion) Config() ent.Config {
|
||||
return ent.Config{
|
||||
Table: "asked_questions",
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ func (Question) Fields() []ent.Field {
|
||||
field.UUID("id", uuid.New()).Immutable(),
|
||||
field.Text("title").MaxLen(256).MinLen(1),
|
||||
field.Int("order"),
|
||||
field.Uint64("defaultLength"), // in milliseconds
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +34,7 @@ func (Question) Edges() []ent.Edge {
|
||||
Unique().
|
||||
Required(),
|
||||
edge.To("choices", Choice.Type),
|
||||
edge.To("current_sessions", Session.Type),
|
||||
edge.To("asked", AskedQuestion.Type),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,12 @@ func (Session) Fields() []ent.Field {
|
||||
field.UUID("id", uuid.New()).Immutable(),
|
||||
field.Time("created").Immutable(),
|
||||
field.Time("started").Nillable().Optional(), // TODO remove?
|
||||
field.Time("current_question_until").Nillable().Optional(),
|
||||
field.String("code").MinLen(6).MaxLen(6).Immutable().Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
func (Session) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
}
|
||||
return []ent.Index{}
|
||||
}
|
||||
|
||||
func (Session) Edges() []ent.Edge {
|
||||
@@ -33,9 +31,7 @@ func (Session) Edges() []ent.Edge {
|
||||
Unique().
|
||||
Required(),
|
||||
edge.To("players", Player.Type),
|
||||
edge.From("current_question", Question.Type).
|
||||
Ref("current_sessions").
|
||||
Unique(),
|
||||
edge.To("askedQuestions", AskedQuestion.Type),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user