fix *
This commit is contained in:
parent
ac5c9d667d
commit
fbe11a2cc1
@ -1466,3 +1466,17 @@ UPDATE bitrixContact SET Field = $1,BitrixID=$3 WHERE ID = $2;
|
||||
|
||||
-- name: UpdateGigaChatQuizFlag :exec
|
||||
UPDATE quiz SET gigachat = true where id = $1 AND accountid = $2 AND deleted = false;
|
||||
|
||||
-- name: GetQuizList :many
|
||||
SELECT * FROM quiz
|
||||
WHERE accountid = sqlc.arg(accountid)
|
||||
AND (sqlc.arg(from_time)::timestamp IS NULL OR created_at >= sqlc.arg(from_time))
|
||||
AND (sqlc.arg(to_time)::timestamp IS NULL OR created_at <= sqlc.arg(to_time))
|
||||
AND (sqlc.arg(deleted)::boolean IS NULL OR deleted = sqlc.arg(deleted))
|
||||
AND (sqlc.arg(archived)::boolean IS NULL OR archived = sqlc.arg(archived))
|
||||
AND (sqlc.arg(super)::boolean IS NULL OR super = sqlc.arg(super))
|
||||
AND (sqlc.arg(group_id)::bigint IS NULL OR group_id = sqlc.arg(group_id))
|
||||
AND (sqlc.arg(status)::text IS NULL OR status = sqlc.arg(status))
|
||||
AND (sqlc.arg(search)::text IS NULL OR to_tsvector('russian', name) @@ plainto_tsquery('russian', sqlc.arg(search)))
|
||||
ORDER BY created_at DESC
|
||||
LIMIT sqlc.arg(limit_pagination) OFFSET sqlc.arg(offset_pagination);
|
@ -3395,6 +3395,101 @@ func (q *Queries) GetQuizHistory(ctx context.Context, arg GetQuizHistoryParams)
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getQuizList = `-- name: GetQuizList :many
|
||||
SELECT id, qid, accountid, deleted, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, super, group_id, name, description, config, status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, created_at, updated_at, questions_count, answers_count, average_time_passing, sessions_count, gigachat FROM quiz
|
||||
WHERE accountid = $1
|
||||
AND ($2::timestamp IS NULL OR created_at >= $2)
|
||||
AND ($3::timestamp IS NULL OR created_at <= $3)
|
||||
AND ($4::boolean IS NULL OR deleted = $4)
|
||||
AND ($5::boolean IS NULL OR archived = $5)
|
||||
AND ($6::boolean IS NULL OR super = $6)
|
||||
AND ($7::bigint IS NULL OR group_id = $7)
|
||||
AND ($8::text IS NULL OR status = $8)
|
||||
AND ($9::text IS NULL OR to_tsvector('russian', name) @@ plainto_tsquery('russian', $9))
|
||||
ORDER BY created_at DESC
|
||||
LIMIT $11 OFFSET $10
|
||||
`
|
||||
|
||||
type GetQuizListParams struct {
|
||||
Accountid string `db:"accountid" json:"accountid"`
|
||||
FromTime time.Time `db:"from_time" json:"from_time"`
|
||||
ToTime time.Time `db:"to_time" json:"to_time"`
|
||||
Deleted bool `db:"deleted" json:"deleted"`
|
||||
Archived bool `db:"archived" json:"archived"`
|
||||
Super bool `db:"super" json:"super"`
|
||||
GroupID int64 `db:"group_id" json:"group_id"`
|
||||
Status string `db:"status" json:"status"`
|
||||
Search string `db:"search" json:"search"`
|
||||
OffsetPagination int32 `db:"offset_pagination" json:"offset_pagination"`
|
||||
LimitPagination int32 `db:"limit_pagination" json:"limit_pagination"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetQuizList(ctx context.Context, arg GetQuizListParams) ([]Quiz, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getQuizList,
|
||||
arg.Accountid,
|
||||
arg.FromTime,
|
||||
arg.ToTime,
|
||||
arg.Deleted,
|
||||
arg.Archived,
|
||||
arg.Super,
|
||||
arg.GroupID,
|
||||
arg.Status,
|
||||
arg.Search,
|
||||
arg.OffsetPagination,
|
||||
arg.LimitPagination,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Quiz
|
||||
for rows.Next() {
|
||||
var i Quiz
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Qid,
|
||||
&i.Accountid,
|
||||
&i.Deleted,
|
||||
&i.Archived,
|
||||
&i.Fingerprinting,
|
||||
&i.Repeatable,
|
||||
&i.NotePrevented,
|
||||
&i.MailNotifications,
|
||||
&i.UniqueAnswers,
|
||||
&i.Super,
|
||||
&i.GroupID,
|
||||
&i.Name,
|
||||
&i.Description,
|
||||
&i.Config,
|
||||
&i.Status,
|
||||
&i.LimitAnswers,
|
||||
&i.DueTo,
|
||||
&i.TimeOfPassing,
|
||||
&i.Pausable,
|
||||
&i.Version,
|
||||
&i.VersionComment,
|
||||
pq.Array(&i.ParentIds),
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.QuestionsCount,
|
||||
&i.AnswersCount,
|
||||
&i.AverageTimePassing,
|
||||
&i.SessionsCount,
|
||||
&i.Gigachat,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getQuizRule = `-- name: GetQuizRule :one
|
||||
SELECT id, accountid, quizid, performerid, pipelineid, stepid, fieldsrule, deleted, createdat, tagstoadd FROM rules WHERE QuizID = $1 AND AccountID = (SELECT AmoID FROM accountsAmo WHERE accountsAmo.AccountID = $2 AND accountsAmo.Deleted = false) AND Deleted = false
|
||||
`
|
||||
|
@ -67,7 +67,11 @@ func (r *QuestionRepository) GetQuestionList(
|
||||
deleted, required bool,
|
||||
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
|
||||
SELECT que.id, que.quiz_id, que.title, que.description, que.questiontype,
|
||||
que.required, que.deleted, que.page, que.content, que.version,
|
||||
que.parent_ids, que.created_at, que.updated_at, que.session, que.auditory
|
||||
FROM question as que
|
||||
JOIN quiz as qui on que.quiz_id = ANY(qui.parent_ids) or que.quiz_id = qui.id
|
||||
%s
|
||||
ORDER BY que.page, que.created_at ASC
|
||||
LIMIT $%d OFFSET $%d;
|
||||
|
@ -90,7 +90,12 @@ func (r *QuizRepository) GetQuizList(
|
||||
ctx context.Context,
|
||||
deps GetQuizListDeps) ([]model.Quiz, uint64, error) {
|
||||
query := `
|
||||
SELECT * FROM quiz
|
||||
SELECT id, qid, accountid, deleted, archived, fingerprinting, repeatable, note_prevented,
|
||||
mail_notifications, unique_answers, super, group_id, name, description, config, status,
|
||||
limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids,
|
||||
created_at, updated_at, questions_count, answers_count, average_time_passing, sessions_count,
|
||||
gigachat
|
||||
FROM quiz
|
||||
%s
|
||||
ORDER BY created_at DESC
|
||||
LIMIT $1 OFFSET $2;
|
||||
@ -202,7 +207,7 @@ func (r *QuizRepository) GetQuizList(
|
||||
&piece.PassedCount,
|
||||
&piece.AverageTime,
|
||||
&piece.SessionCount,
|
||||
&piece.GigaChat,
|
||||
&piece.GigaChat,
|
||||
); err != nil {
|
||||
qerr = err
|
||||
return
|
||||
@ -261,7 +266,11 @@ func (r *QuizRepository) GetQuizByQid(ctx context.Context, qid string) (model.Qu
|
||||
}
|
||||
|
||||
fmt.Println("QUID", `
|
||||
SELECT * FROM quiz
|
||||
SELECT id, qid, accountid, deleted, archived, fingerprinting, repeatable, note_prevented,
|
||||
mail_notifications, unique_answers, super, group_id, name, description, config, status,
|
||||
limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids,
|
||||
created_at, updated_at, questions_count, answers_count, average_time_passing, sessions_count,
|
||||
gigachat FROM quiz
|
||||
WHERE
|
||||
deleted = false AND
|
||||
archived = false AND
|
||||
@ -269,7 +278,11 @@ WHERE
|
||||
qid = $1;
|
||||
`)
|
||||
rows, err := r.pool.QueryContext(ctx, `
|
||||
SELECT * FROM quiz
|
||||
SELECT id, qid, accountid, deleted, archived, fingerprinting, repeatable, note_prevented,
|
||||
mail_notifications, unique_answers, super, group_id, name, description, config, status,
|
||||
limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids,
|
||||
created_at, updated_at, questions_count, answers_count, average_time_passing, sessions_count,
|
||||
gigachat FROM quiz
|
||||
WHERE
|
||||
deleted = false AND
|
||||
archived = false AND
|
||||
@ -317,7 +330,7 @@ WHERE
|
||||
&piece.PassedCount,
|
||||
&piece.AverageTime,
|
||||
&piece.SessionCount,
|
||||
&piece.GigaChat,
|
||||
&piece.GigaChat,
|
||||
); err != nil {
|
||||
return model.Quiz{}, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user