update answer create method, add utm to it
This commit is contained in:
parent
da0213dd93
commit
55bdce51ff
@ -3,6 +3,7 @@ package answer
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal/sqlcgen"
|
||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||
)
|
||||
@ -40,6 +41,11 @@ func (r *AnswerRepository) CreateAnswers(ctx context.Context, answers []model.An
|
||||
}
|
||||
|
||||
for _, ans := range answers {
|
||||
utmJSON, err := json.Marshal(ans.Utm)
|
||||
if err != nil {
|
||||
return nil, []error{err}
|
||||
}
|
||||
|
||||
params := sqlcgen.InsertAnswersParams{
|
||||
Content: sql.NullString{String: ans.Content, Valid: true},
|
||||
QuizID: int64(quizID),
|
||||
@ -54,9 +60,10 @@ func (r *AnswerRepository) CreateAnswers(ctx context.Context, answers []model.An
|
||||
Browser: ans.Browser,
|
||||
Os: ans.OS,
|
||||
Start: ans.Start,
|
||||
Utm: utmJSON,
|
||||
}
|
||||
|
||||
err := r.queries.InsertAnswers(ctx, params)
|
||||
err = r.queries.InsertAnswers(ctx, params)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user