update sqlc gen
This commit is contained in:
parent
718380f2de
commit
9b29570c02
@ -569,30 +569,42 @@ FROM
|
|||||||
WHERE
|
WHERE
|
||||||
Questions.percentage >= 1;
|
Questions.percentage >= 1;
|
||||||
|
|
||||||
-- name: QuizMove :many
|
-- name: QuizCopyQid :one
|
||||||
WITH copy AS (
|
WITH original_quiz 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 id
|
||||||
SELECT
|
FROM quiz
|
||||||
uuid_generate_v4(),
|
WHERE quiz.qid = $1 AND quiz.accountId = $2
|
||||||
$2,
|
),
|
||||||
fingerprinting,repeatable,note_prevented,mail_notifications,unique_answers,super,
|
new_quiz AS (
|
||||||
group_id,name,description,config,status,limit_answers,due_to,time_of_passing,
|
INSERT INTO quiz (
|
||||||
pausable,version,version_comment,parent_ids,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,
|
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||||
questions_count,answers_count,average_time_passing
|
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
|
SELECT
|
||||||
WHERE
|
accountid, archived, fingerprinting, repeatable, note_prevented, mail_notifications, unique_answers, name, description, config,
|
||||||
qid = $1
|
status, limit_answers, due_to, time_of_passing, pausable, version, version_comment, parent_ids, questions_count, answers_count, average_time_passing, super, group_id
|
||||||
RETURNING id, qid
|
FROM
|
||||||
)
|
quiz
|
||||||
INSERT INTO question (quiz_id, title, description, questiontype, required, deleted, page, content, version, parent_ids, created_at, updated_at)
|
WHERE
|
||||||
|
qid = $1 AND accountId = $2
|
||||||
|
RETURNING id,qid
|
||||||
|
)
|
||||||
SELECT
|
SELECT
|
||||||
cq.id,title,description,questiontype, required,deleted,page,
|
original_quiz.id AS original_quiz_id,
|
||||||
content,version,parent_ids,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP
|
new_quiz.id AS new_quiz_id,
|
||||||
|
new_quiz.qid AS original_qid
|
||||||
FROM
|
FROM
|
||||||
question q
|
original_quiz, new_quiz;
|
||||||
JOIN
|
|
||||||
copy cq ON q.quiz_id = cq.qid
|
-- name: CopyQuestionQuizID :exec
|
||||||
WHERE
|
INSERT INTO question (
|
||||||
q.deleted = false
|
quiz_id, title, description, questiontype, required,
|
||||||
RETURNING cq.qid;
|
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
|
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
|
const copyQuiz = `-- name: CopyQuiz :one
|
||||||
INSERT INTO quiz(
|
INSERT INTO quiz(
|
||||||
accountid, archived,fingerprinting,repeatable,note_prevented,mail_notifications,unique_answers,name,description,config,
|
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
|
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
|
const softDeleteResultByID = `-- name: SoftDeleteResultByID :exec
|
||||||
UPDATE answer SET deleted = TRUE WHERE id = $1 AND deleted = FALSE
|
UPDATE answer SET deleted = TRUE WHERE id = $1 AND deleted = FALSE
|
||||||
`
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user