add device, browser etc to answers obtaining

This commit is contained in:
skeris 2024-04-01 01:30:38 +03:00
parent 208dcd8924
commit 5bd4114f60
3 changed files with 17 additions and 2 deletions

@ -312,7 +312,7 @@ INSERT INTO answer(
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);
-- name: GetResultAnswers :many
SELECT DISTINCT on (question_id) id, content, quiz_id, question_id, fingerprint, session,created_at, result, new,deleted FROM answer WHERE session = (
SELECT DISTINCT on (question_id) id, content, quiz_id, question_id, fingerprint, session,created_at, result, new,deleted, device_type,device,os,browser,ip FROM answer WHERE session = (
SELECT session FROM answer WHERE answer.id = $1) AND start = false ORDER BY question_id, created_at DESC;
-- name: GetQuestions :many

@ -1341,7 +1341,7 @@ func (q *Queries) GetQuizHistory(ctx context.Context, arg GetQuizHistoryParams)
}
const getResultAnswers = `-- name: GetResultAnswers :many
SELECT DISTINCT on (question_id) id, content, quiz_id, question_id, fingerprint, session,created_at, result, new,deleted FROM answer WHERE session = (
SELECT DISTINCT on (question_id) id, content, quiz_id, question_id, fingerprint, session,created_at, result, new,deleted, device_type,device,os,browser,ip FROM answer WHERE session = (
SELECT session FROM answer WHERE answer.id = $1) AND start = false ORDER BY question_id, created_at DESC
`
@ -1356,6 +1356,11 @@ type GetResultAnswersRow struct {
Result sql.NullBool `db:"result" json:"result"`
New sql.NullBool `db:"new" json:"new"`
Deleted sql.NullBool `db:"deleted" json:"deleted"`
DeviceType string `db:"device_type" json:"device_type"`
Device string `db:"device" json:"device"`
Os string `db:"os" json:"os"`
Browser string `db:"browser" json:"browser"`
Ip string `db:"ip" json:"ip"`
}
func (q *Queries) GetResultAnswers(ctx context.Context, id int64) ([]GetResultAnswersRow, error) {
@ -1378,6 +1383,11 @@ func (q *Queries) GetResultAnswers(ctx context.Context, id int64) ([]GetResultAn
&i.Result,
&i.New,
&i.Deleted,
&i.DeviceType,
&i.Device,
&i.Os,
&i.Browser,
&i.Ip,
); err != nil {
return nil, err
}

@ -240,6 +240,11 @@ func (r *ResultRepository) GetResultAnswers(ctx context.Context, answerID uint64
CreatedAt: row.CreatedAt.Time,
New: row.New.Bool,
Deleted: row.Deleted.Bool,
Device: row.Device,
DeviceType: row.DeviceType,
OS: row.Os,
IP: row.Ip,
Browser: row.Browser,
}
answers = append(answers, answer)