upd GetQuestionsAICount

This commit is contained in:
pasha1coil 2025-06-30 13:39:16 +03:00
parent 5656e784ba
commit e37fd29078
3 changed files with 9 additions and 7 deletions

@ -1101,7 +1101,7 @@ ORDER BY (q.session != '') ASC, --без сессии первые потом с
LIMIT $4 OFFSET $5;
-- name: GetQuestionsAICount :one
SELECT COUNT(*) AS count FROM question WHERE quiz_id = $1 AND (session = $2 OR session = '') AND deleted = FALSE;
SELECT COUNT(*) AS count FROM question WHERE quiz_id = $1 AND auditory = $2 AND (session = $3 OR session = '') AND deleted = FALSE;
-- name: CreateQuizAudience :one
INSERT INTO gigachatAudience (QuizID, Sex, Age) VALUES ($1, $2, $3) RETURNING ID;

@ -3219,16 +3219,17 @@ func (q *Queries) GetQuestionsAI(ctx context.Context, arg GetQuestionsAIParams)
}
const getQuestionsAICount = `-- name: GetQuestionsAICount :one
SELECT COUNT(*) AS count FROM question WHERE quiz_id = $1 AND (session = $2 OR session = '') AND deleted = FALSE
SELECT COUNT(*) AS count FROM question WHERE quiz_id = $1 AND auditory = $2 AND (session = $3 OR session = '') AND deleted = FALSE
`
type GetQuestionsAICountParams struct {
QuizID int64 `db:"quiz_id" json:"quiz_id"`
Session string `db:"session" json:"session"`
QuizID int64 `db:"quiz_id" json:"quiz_id"`
Auditory int64 `db:"auditory" json:"auditory"`
Session string `db:"session" json:"session"`
}
func (q *Queries) GetQuestionsAICount(ctx context.Context, arg GetQuestionsAICountParams) (int64, error) {
row := q.db.QueryRowContext(ctx, getQuestionsAICount, arg.QuizID, arg.Session)
row := q.db.QueryRowContext(ctx, getQuestionsAICount, arg.QuizID, arg.Auditory, arg.Session)
var count int64
err := row.Scan(&count)
return count, err

@ -538,8 +538,9 @@ func (r *QuestionRepository) GetQuestionsAI(ctx context.Context, quizID int64, s
}
count, err = r.queries.GetQuestionsAICount(ctx, sqlcgen.GetQuestionsAICountParams{
QuizID: quizID,
Session: session,
QuizID: quizID,
Session: session,
Auditory: auditory,
})
return questions, uint64(count), nil