Fill Session.Started

This commit is contained in:
Vojtěch Káně
2021-03-24 19:30:00 +01:00
parent e2e7130e40
commit 782f96ebbd
2 changed files with 5 additions and 1 deletions

View File

@@ -188,6 +188,10 @@ func (m *Model) NextQuestion(sessionId uuid.UUID, now time.Time, c context.Conte
// TODO rollback only if not yet committed
defer tx.Rollback()
if err := tx.Session.Update().Where(session.ID(sessionId)).Where(session.StartedIsNil()).SetStarted(now).Exec(c); err != nil {
return err
}
var query = tx.Question.Query().Where(question.HasGameWith(game.HasSessionsWith(session.ID(sessionId)))).Order(ent.Asc(question.FieldOrder))
if current, err := tx.AskedQuestion.Query().Where(askedquestion.HasSessionWith(session.ID(sessionId))).WithQuestion().Order(ent.Desc(askedquestion.FieldAsked)).First(c); err == nil {