update sqlc gen
This commit is contained in:
parent
ebf5c9f4de
commit
b6b8f67cb6
@ -932,15 +932,17 @@ WITH user_data AS (
|
||||
)
|
||||
SELECT * from inserted_utms;
|
||||
|
||||
-- name: GetQuizRule
|
||||
-- name: GetQuizRule :one
|
||||
SELECT * FROM rules WHERE QuizID = $1 AND Deleted = false;
|
||||
|
||||
-- name: SetQuizSettings
|
||||
-- name: SetQuizSettings :one
|
||||
INSERT INTO rules (AccountID, QuizID, PerformerID, PipelineID, StepID, UTMS, FieldsRule)
|
||||
SELECT u.AmoID AS AccountID,$1 AS QuizID,$2 AS PerformerID,$3 AS PipelineID,
|
||||
$4 AS StepID,$5 AS UTMS,$6 AS FieldsRule FROM users u WHERE u.AccountID = $7;
|
||||
$4 AS StepID,$5 AS UTMS,$6 AS FieldsRule FROM users u WHERE u.AccountID = $7
|
||||
RETURNING *;
|
||||
|
||||
-- name: ChangeQuizSettings
|
||||
-- name: ChangeQuizSettings :one
|
||||
UPDATE rules
|
||||
SET PerformerID = $1,PipelineID = $2,StepID = $3,UTMS = $4,FieldsRule = $5
|
||||
WHERE AccountID = (SELECT AmoID FROM users WHERE AccountID = $6) AND QuizID = $7;
|
||||
WHERE AccountID = (SELECT AmoID FROM users WHERE users.AccountID = $6) AND QuizID = $7
|
||||
RETURNING *;
|
||||
|
@ -114,6 +114,49 @@ func (q *Queries) ArchiveQuiz(ctx context.Context, arg ArchiveQuizParams) error
|
||||
return err
|
||||
}
|
||||
|
||||
const changeQuizSettings = `-- name: ChangeQuizSettings :one
|
||||
UPDATE rules
|
||||
SET PerformerID = $1,PipelineID = $2,StepID = $3,UTMS = $4,FieldsRule = $5
|
||||
WHERE AccountID = (SELECT AmoID FROM users WHERE users.AccountID = $6) AND QuizID = $7
|
||||
RETURNING id, accountid, quizid, performerid, pipelineid, stepid, utms, fieldsrule, deleted, createdat
|
||||
`
|
||||
|
||||
type ChangeQuizSettingsParams struct {
|
||||
Performerid int32 `db:"performerid" json:"performerid"`
|
||||
Pipelineid int32 `db:"pipelineid" json:"pipelineid"`
|
||||
Stepid int32 `db:"stepid" json:"stepid"`
|
||||
Utms []int32 `db:"utms" json:"utms"`
|
||||
Fieldsrule json.RawMessage `db:"fieldsrule" json:"fieldsrule"`
|
||||
Accountid string `db:"accountid" json:"accountid"`
|
||||
Quizid int32 `db:"quizid" json:"quizid"`
|
||||
}
|
||||
|
||||
func (q *Queries) ChangeQuizSettings(ctx context.Context, arg ChangeQuizSettingsParams) (Rule, error) {
|
||||
row := q.db.QueryRowContext(ctx, changeQuizSettings,
|
||||
arg.Performerid,
|
||||
arg.Pipelineid,
|
||||
arg.Stepid,
|
||||
pq.Array(arg.Utms),
|
||||
arg.Fieldsrule,
|
||||
arg.Accountid,
|
||||
arg.Quizid,
|
||||
)
|
||||
var i Rule
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Accountid,
|
||||
&i.Quizid,
|
||||
&i.Performerid,
|
||||
&i.Pipelineid,
|
||||
&i.Stepid,
|
||||
pq.Array(&i.Utms),
|
||||
&i.Fieldsrule,
|
||||
&i.Deleted,
|
||||
&i.Createdat,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const checkAndAddDefault = `-- name: CheckAndAddDefault :exec
|
||||
UPDATE privileges
|
||||
SET amount = $1, created_at = NOW()
|
||||
@ -1965,6 +2008,28 @@ func (q *Queries) GetQuizHistory(ctx context.Context, arg GetQuizHistoryParams)
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getQuizRule = `-- name: GetQuizRule :one
|
||||
SELECT id, accountid, quizid, performerid, pipelineid, stepid, utms, fieldsrule, deleted, createdat FROM rules WHERE QuizID = $1 AND Deleted = false
|
||||
`
|
||||
|
||||
func (q *Queries) GetQuizRule(ctx context.Context, quizid int32) (Rule, error) {
|
||||
row := q.db.QueryRowContext(ctx, getQuizRule, quizid)
|
||||
var i Rule
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Accountid,
|
||||
&i.Quizid,
|
||||
&i.Performerid,
|
||||
&i.Pipelineid,
|
||||
&i.Stepid,
|
||||
pq.Array(&i.Utms),
|
||||
&i.Fieldsrule,
|
||||
&i.Deleted,
|
||||
&i.Createdat,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getResultAnswers = `-- name: GetResultAnswers :many
|
||||
SELECT DISTINCT on (question_id) id, content, quiz_id, question_id, fingerprint, session,created_at, result, new,deleted, device_type,device,os,browser,ip FROM answer WHERE session = (
|
||||
SELECT session FROM answer WHERE answer.id = $1) ORDER BY question_id, created_at DESC
|
||||
@ -2815,6 +2880,49 @@ func (q *Queries) SaveUTMs(ctx context.Context, arg SaveUTMsParams) ([]SaveUTMsR
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setQuizSettings = `-- name: SetQuizSettings :one
|
||||
INSERT INTO rules (AccountID, QuizID, PerformerID, PipelineID, StepID, UTMS, FieldsRule)
|
||||
SELECT u.AmoID AS AccountID,$1 AS QuizID,$2 AS PerformerID,$3 AS PipelineID,
|
||||
$4 AS StepID,$5 AS UTMS,$6 AS FieldsRule FROM users u WHERE u.AccountID = $7
|
||||
RETURNING id, accountid, quizid, performerid, pipelineid, stepid, utms, fieldsrule, deleted, createdat
|
||||
`
|
||||
|
||||
type SetQuizSettingsParams struct {
|
||||
Quizid int32 `db:"quizid" json:"quizid"`
|
||||
Performerid int32 `db:"performerid" json:"performerid"`
|
||||
Pipelineid int32 `db:"pipelineid" json:"pipelineid"`
|
||||
Stepid int32 `db:"stepid" json:"stepid"`
|
||||
Utms []int32 `db:"utms" json:"utms"`
|
||||
Fieldsrule json.RawMessage `db:"fieldsrule" json:"fieldsrule"`
|
||||
Accountid string `db:"accountid" json:"accountid"`
|
||||
}
|
||||
|
||||
func (q *Queries) SetQuizSettings(ctx context.Context, arg SetQuizSettingsParams) (Rule, error) {
|
||||
row := q.db.QueryRowContext(ctx, setQuizSettings,
|
||||
arg.Quizid,
|
||||
arg.Performerid,
|
||||
arg.Pipelineid,
|
||||
arg.Stepid,
|
||||
pq.Array(arg.Utms),
|
||||
arg.Fieldsrule,
|
||||
arg.Accountid,
|
||||
)
|
||||
var i Rule
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Accountid,
|
||||
&i.Quizid,
|
||||
&i.Performerid,
|
||||
&i.Pipelineid,
|
||||
&i.Stepid,
|
||||
pq.Array(&i.Utms),
|
||||
&i.Fieldsrule,
|
||||
&i.Deleted,
|
||||
&i.Createdat,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const softDeleteAccount = `-- name: SoftDeleteAccount :exec
|
||||
UPDATE users SET Deleted = TRUE WHERE AccountID = $1
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user