add page sort for getting questions page
This commit is contained in:
parent
40d8b15b24
commit
a84f95429f
@ -313,7 +313,7 @@ SELECT DISTINCT on (question_id) id, content, quiz_id, question_id, fingerprint,
|
|||||||
SELECT session FROM answer WHERE answer.id = $1) ORDER BY question_id, created_at DESC;
|
SELECT session FROM answer WHERE answer.id = $1) ORDER BY question_id, created_at DESC;
|
||||||
|
|
||||||
-- name: GetQuestions :many
|
-- name: GetQuestions :many
|
||||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE quiz_id = $1 AND deleted = FALSE;
|
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE quiz_id = $1 AND deleted = FALSE ORDER BY page ASC;
|
||||||
|
|
||||||
-- name: SoftDeleteResultByID :exec
|
-- name: SoftDeleteResultByID :exec
|
||||||
UPDATE answer SET deleted = TRUE WHERE id = $1 AND deleted = FALSE;
|
UPDATE answer SET deleted = TRUE WHERE id = $1 AND deleted = FALSE;
|
||||||
|
@ -1118,7 +1118,7 @@ func (q *Queries) GetQuestionTitle(ctx context.Context, id int64) (GetQuestionTi
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getQuestions = `-- name: GetQuestions :many
|
const getQuestions = `-- name: GetQuestions :many
|
||||||
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE quiz_id = $1 AND deleted = FALSE
|
SELECT id, quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at FROM question WHERE quiz_id = $1 AND deleted = FALSE ORDER BY page ASC
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) GetQuestions(ctx context.Context, quizID int64) ([]Question, error) {
|
func (q *Queries) GetQuestions(ctx context.Context, quizID int64) ([]Question, error) {
|
||||||
|
@ -141,7 +141,7 @@ func (r *ResultRepository) GetQuizResultsCSV(ctx context.Context, quizID uint64,
|
|||||||
WHERE a2.session = a.session AND a2.result = TRUE AND a2.quiz_id = a.quiz_id
|
WHERE a2.session = a.session AND a2.result = TRUE AND a2.quiz_id = a.quiz_id
|
||||||
)`
|
)`
|
||||||
|
|
||||||
mainQuery += ` ORDER BY a.question_id, a.session, a.created_at DESC, a.result DESC`
|
mainQuery += ` ORDER BY a.session, a.question_id ASC, a.created_at DESC, a.result DESC`
|
||||||
|
|
||||||
rows, err := r.pool.QueryContext(ctx, mainQuery, queryParams...)
|
rows, err := r.pool.QueryContext(ctx, mainQuery, queryParams...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user