update sqlc gen
This commit is contained in:
parent
718380f2de
commit
9b29570c02
@ -569,30 +569,42 @@ FROM
|
||||
WHERE
|
||||
Questions.percentage >= 1;
|
||||
|
||||
-- name: QuizMove :many
|
||||
WITH copy AS (
|
||||
INSERT INTO quiz (qid, accountid,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)
|
||||
SELECT
|
||||
uuid_generate_v4(),
|
||||
$2,
|
||||
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,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,
|
||||
questions_count,answers_count,average_time_passing
|
||||
FROM
|
||||
quiz
|
||||
WHERE
|
||||
qid = $1
|
||||
RETURNING id, qid
|
||||
)
|
||||
INSERT INTO question (quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at)
|
||||
-- name: QuizCopyQid :one
|
||||
WITH original_quiz AS (
|
||||
SELECT id
|
||||
FROM quiz
|
||||
WHERE quiz.qid = $1 AND quiz.accountId = $2
|
||||
),
|
||||
new_quiz AS (
|
||||
INSERT INTO quiz (
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
)
|
||||
SELECT
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
FROM
|
||||
quiz
|
||||
WHERE
|
||||
qid = $1 AND accountId = $2
|
||||
RETURNING id,qid
|
||||
)
|
||||
SELECT
|
||||
cq.id,title,description,questiontype, required,deleted,page,
|
||||
content,version,parent_ids,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
||||
original_quiz.id AS original_quiz_id,
|
||||
new_quiz.id AS new_quiz_id,
|
||||
new_quiz.qid AS original_qid
|
||||
FROM
|
||||
question q
|
||||
JOIN
|
||||
copy cq ON q.quiz_id = cq.qid
|
||||
WHERE
|
||||
q.deleted = false
|
||||
RETURNING cq.qid;
|
||||
original_quiz, new_quiz;
|
||||
|
||||
-- name: CopyQuestionQuizID :exec
|
||||
INSERT INTO question (
|
||||
quiz_id, title, description, questiontype, required,
|
||||
page, content, version, parent_ids, created_at, updated_at
|
||||
)
|
||||
SELECT
|
||||
$2, title, description, questiontype, required,
|
||||
page, content, version, parent_ids, created_at, updated_at
|
||||
FROM
|
||||
question
|
||||
WHERE
|
||||
question.quiz_id = $1 AND deleted = false;
|
||||
|
@ -172,6 +172,30 @@ func (q *Queries) CopyQuestion(ctx context.Context, arg CopyQuestionParams) (Cop
|
||||
return i, err
|
||||
}
|
||||
|
||||
const copyQuestionQuizID = `-- name: CopyQuestionQuizID :exec
|
||||
INSERT INTO question (
|
||||
quiz_id, title, description, questiontype, required,
|
||||
page, content, version, parent_ids, created_at, updated_at
|
||||
)
|
||||
SELECT
|
||||
$2, title, description, questiontype, required,
|
||||
page, content, version, parent_ids, created_at, updated_at
|
||||
FROM
|
||||
question
|
||||
WHERE
|
||||
question.quiz_id = $1 AND deleted = false
|
||||
`
|
||||
|
||||
type CopyQuestionQuizIDParams struct {
|
||||
QuizID int64 `db:"quiz_id" json:"quiz_id"`
|
||||
QuizID_2 int64 `db:"quiz_id_2" json:"quiz_id_2"`
|
||||
}
|
||||
|
||||
func (q *Queries) CopyQuestionQuizID(ctx context.Context, arg CopyQuestionQuizIDParams) error {
|
||||
_, err := q.db.ExecContext(ctx, copyQuestionQuizID, arg.QuizID, arg.QuizID_2)
|
||||
return err
|
||||
}
|
||||
|
||||
const copyQuiz = `-- name: CopyQuiz :one
|
||||
INSERT INTO quiz(
|
||||
accountid, archived,fingerprinting,repeatable,note_prevented,mail_notifications,unique_answers,name,description,config,
|
||||
@ -1715,6 +1739,52 @@ func (q *Queries) QuestionsStatistics(ctx context.Context, arg QuestionsStatisti
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const quizCopyQid = `-- name: QuizCopyQid :one
|
||||
WITH original_quiz AS (
|
||||
SELECT id
|
||||
FROM quiz
|
||||
WHERE quiz.qid = $1 AND quiz.accountId = $2
|
||||
),
|
||||
new_quiz AS (
|
||||
INSERT INTO quiz (
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
)
|
||||
SELECT
|
||||
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||
FROM
|
||||
quiz
|
||||
WHERE
|
||||
qid = $1 AND accountId = $2
|
||||
RETURNING id,qid
|
||||
)
|
||||
SELECT
|
||||
original_quiz.id AS original_quiz_id,
|
||||
new_quiz.id AS new_quiz_id,
|
||||
new_quiz.qid AS original_qid
|
||||
FROM
|
||||
original_quiz, new_quiz
|
||||
`
|
||||
|
||||
type QuizCopyQidParams struct {
|
||||
Qid uuid.NullUUID `db:"qid" json:"qid"`
|
||||
Accountid string `db:"accountid" json:"accountid"`
|
||||
}
|
||||
|
||||
type QuizCopyQidRow struct {
|
||||
OriginalQuizID int64 `db:"original_quiz_id" json:"original_quiz_id"`
|
||||
NewQuizID int64 `db:"new_quiz_id" json:"new_quiz_id"`
|
||||
OriginalQid uuid.NullUUID `db:"original_qid" json:"original_qid"`
|
||||
}
|
||||
|
||||
func (q *Queries) QuizCopyQid(ctx context.Context, arg QuizCopyQidParams) (QuizCopyQidRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, quizCopyQid, arg.Qid, arg.Accountid)
|
||||
var i QuizCopyQidRow
|
||||
err := row.Scan(&i.OriginalQuizID, &i.NewQuizID, &i.OriginalQid)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const softDeleteResultByID = `-- name: SoftDeleteResultByID :exec
|
||||
UPDATE answer SET deleted = TRUE WHERE id = $1 AND deleted = FALSE
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user