This commit is contained in:
Pasha 2025-06-11 17:10:00 +03:00
parent fbe11a2cc1
commit ddd0219fb3
2 changed files with 1 additions and 110 deletions

@ -1465,18 +1465,4 @@ INSERT INTO bitrixContact (AccountID, BitrixID, Field) VALUES ($1, $2, $3) RETUR
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);
UPDATE quiz SET gigachat = true where id = $1 AND accountid = $2 AND deleted = false;

@ -3395,101 +3395,6 @@ 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
`