upd with column auditory

This commit is contained in:
Pasha 2025-05-14 15:33:32 +03:00
parent d27fa4798a
commit 670c3afd4e
2 changed files with 4 additions and 4 deletions

@ -1094,7 +1094,7 @@ UPDATE amoContact SET Field = $1,AmoID=$3 WHERE ID = $2;
-- name: GetQuestionsAI :many
SELECT q.id, q.quiz_id, q.title, q.description, q.questiontype, q.required, q.deleted, q.page, q.content, q.version, q.parent_ids, q.created_at, q.updated_at, q.session,q.auditory FROM question q
WHERE q.quiz_id = $1 AND (q.session = $2 OR q.session = '') AND q.deleted = FALSE
WHERE q.quiz_id = $1 AND (q.session = $2 OR q.session = '') AND q.deleted = FALSE AND q.auditory = $3
ORDER BY (q.session != '') ASC, --без сессии первые потом с сессией
q.page, --по возрастанию страницы
q.created_at --по времени создания

@ -65,7 +65,7 @@ func (r *QuestionRepository) GetQuestionList(
ctx context.Context,
limit, offset, from, to, quizId uint64,
deleted, required bool,
search, qType string) ([]model.Question, uint64, error) {
search, qType string, auditory int64) ([]model.Question, uint64, error) {
query := `
SELECT que.* FROM question as que JOIN quiz as qui on que.quiz_id = ANY(qui.parent_ids) or que.quiz_id = qui.id
%s
@ -111,7 +111,7 @@ func (r *QuestionRepository) GetQuestionList(
whereClause = append(whereClause, fmt.Sprintf("to_tsvector('russian', que.title) @@ to_tsquery('russian', $%d)", len(data)))
}
whereClause = append(whereClause, "que.auditory = 0")
whereClause = append(whereClause, fmt.Sprintf("que.auditory = %d", auditory))
data = append(data, limit, offset)
if len(whereClause) != 0 {
@ -498,7 +498,7 @@ func (r *QuestionRepository) GetQuestionListByIDs(ctx context.Context, ids []int
return questions, nil
}
func (r *QuestionRepository) GetQuestionsAI(ctx context.Context, quizID int64, session string, limit, offset int32) ([]model.Question, uint64, error) {
func (r *QuestionRepository) GetQuestionsAI(ctx context.Context, quizID int64, session string, limit, offset int32, auditory) ([]model.Question, uint64, error) {
rows, err := r.queries.GetQuestionsAI(ctx, sqlcgen.GetQuestionsAIParams{
QuizID: quizID,
Session: session,