fix pagination methods in repo amo and GetQuestionsAI
This commit is contained in:
parent
1fdb13e16e
commit
7f57d8c289
@ -53,11 +53,15 @@ func (r *AmoRepository) GettingUserWithPagination(ctx context.Context, req *mode
|
|||||||
Deleted: row.Deleted,
|
Deleted: row.Deleted,
|
||||||
CreatedAt: row.Createdat,
|
CreatedAt: row.Createdat,
|
||||||
}
|
}
|
||||||
count = row.TotalCount
|
|
||||||
|
|
||||||
users = append(users, user)
|
users = append(users, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count, err = r.queries.GetUsersCount(ctx, accountID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
resp := model.UserListResp{
|
resp := model.UserListResp{
|
||||||
Count: count,
|
Count: count,
|
||||||
Items: users,
|
Items: users,
|
||||||
@ -299,7 +303,6 @@ func (r *AmoRepository) GetPipelinesWithPagination(ctx context.Context, req *mod
|
|||||||
var pipelines []model.Pipeline
|
var pipelines []model.Pipeline
|
||||||
|
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
count = row.TotalCount
|
|
||||||
pipeline := model.Pipeline{
|
pipeline := model.Pipeline{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
Amoid: row.Amoid,
|
Amoid: row.Amoid,
|
||||||
@ -311,6 +314,11 @@ func (r *AmoRepository) GetPipelinesWithPagination(ctx context.Context, req *mod
|
|||||||
pipelines = append(pipelines, pipeline)
|
pipelines = append(pipelines, pipeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count, err = r.queries.GetPipelinesCount(ctx, accountID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
resp := model.UserListPipelinesResp{
|
resp := model.UserListPipelinesResp{
|
||||||
Count: count,
|
Count: count,
|
||||||
Items: pipelines,
|
Items: pipelines,
|
||||||
@ -400,7 +408,6 @@ func (r *AmoRepository) GetStepsWithPagination(ctx context.Context, req *model.P
|
|||||||
var steps []model.Step
|
var steps []model.Step
|
||||||
|
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
count = row.TotalCount
|
|
||||||
step := model.Step{
|
step := model.Step{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
Amoid: row.Amoid,
|
Amoid: row.Amoid,
|
||||||
@ -413,6 +420,14 @@ func (r *AmoRepository) GetStepsWithPagination(ctx context.Context, req *model.P
|
|||||||
steps = append(steps, step)
|
steps = append(steps, step)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count, err = r.queries.GetStepsCount(ctx, sqlcgen.GetStepsCountParams{
|
||||||
|
Accountid: accountID,
|
||||||
|
Pipelineid: pipelineID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
resp := model.UserListStepsResp{
|
resp := model.UserListStepsResp{
|
||||||
Count: count,
|
Count: count,
|
||||||
Items: steps,
|
Items: steps,
|
||||||
@ -505,8 +520,6 @@ func (r *AmoRepository) GetTagsWithPagination(ctx context.Context, req *model.Pa
|
|||||||
var count int64
|
var count int64
|
||||||
var tags []model.Tag
|
var tags []model.Tag
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
count = row.TotalCount
|
|
||||||
|
|
||||||
var entity model.EntityType
|
var entity model.EntityType
|
||||||
v := string(row.Entity.([]byte))
|
v := string(row.Entity.([]byte))
|
||||||
entity = model.EntityType(v)
|
entity = model.EntityType(v)
|
||||||
@ -523,6 +536,11 @@ func (r *AmoRepository) GetTagsWithPagination(ctx context.Context, req *model.Pa
|
|||||||
tags = append(tags, tag)
|
tags = append(tags, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count, err = r.queries.GetTagsCount(ctx, accountID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
resp := model.UserListTagsResp{
|
resp := model.UserListTagsResp{
|
||||||
Count: count,
|
Count: count,
|
||||||
Items: tags,
|
Items: tags,
|
||||||
@ -625,8 +643,6 @@ func (r *AmoRepository) GetFieldsWithPagination(ctx context.Context, req *model.
|
|||||||
var fields []model.Field
|
var fields []model.Field
|
||||||
|
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
count = row.TotalCount
|
|
||||||
|
|
||||||
var entity model.EntityType
|
var entity model.EntityType
|
||||||
v := string(row.Entity.([]byte))
|
v := string(row.Entity.([]byte))
|
||||||
entity = model.EntityType(v)
|
entity = model.EntityType(v)
|
||||||
@ -649,6 +665,11 @@ func (r *AmoRepository) GetFieldsWithPagination(ctx context.Context, req *model.
|
|||||||
fields = append(fields, field)
|
fields = append(fields, field)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count, err = r.queries.GetFieldsCount(ctx, accountID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
resp := model.UserListFieldsResp{
|
resp := model.UserListFieldsResp{
|
||||||
Count: count,
|
Count: count,
|
||||||
Items: fields,
|
Items: fields,
|
||||||
@ -830,7 +851,7 @@ func (r *AmoRepository) SetQuizSettings(ctx context.Context, request *model.Rule
|
|||||||
|
|
||||||
func (r *AmoRepository) GettingQuizRules(ctx context.Context, accountID string, quizID int) (*model.Rule, error) {
|
func (r *AmoRepository) GettingQuizRules(ctx context.Context, accountID string, quizID int) (*model.Rule, error) {
|
||||||
row, err := r.queries.GetQuizRule(ctx, sqlcgen.GetQuizRuleParams{
|
row, err := r.queries.GetQuizRule(ctx, sqlcgen.GetQuizRuleParams{
|
||||||
Quizid: int32(quizID),
|
Quizid: int32(quizID),
|
||||||
Accountid: accountID,
|
Accountid: accountID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -5,9 +5,9 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/lib/pq"
|
|
||||||
"gitea.pena/SQuiz/common/dal/sqlcgen"
|
"gitea.pena/SQuiz/common/dal/sqlcgen"
|
||||||
"gitea.pena/SQuiz/common/model"
|
"gitea.pena/SQuiz/common/model"
|
||||||
|
"github.com/lib/pq"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -160,7 +160,7 @@ func (r *QuestionRepository) GetQuestionList(
|
|||||||
&pIds,
|
&pIds,
|
||||||
&piece.CreatedAt,
|
&piece.CreatedAt,
|
||||||
&piece.UpdatedAt,
|
&piece.UpdatedAt,
|
||||||
&piece.Session,
|
&piece.Session,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
qerr = err
|
qerr = err
|
||||||
return
|
return
|
||||||
@ -500,11 +500,9 @@ func (r *QuestionRepository) GetQuestionsAI(ctx context.Context, quizID int64, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
var questions []model.Question
|
var questions []model.Question
|
||||||
var count uint64
|
var count int64
|
||||||
|
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
count = uint64(row.Count)
|
|
||||||
|
|
||||||
questions = append(questions, model.Question{
|
questions = append(questions, model.Question{
|
||||||
Id: uint64(row.ID),
|
Id: uint64(row.ID),
|
||||||
QuizId: uint64(row.QuizID),
|
QuizId: uint64(row.QuizID),
|
||||||
@ -523,5 +521,10 @@ func (r *QuestionRepository) GetQuestionsAI(ctx context.Context, quizID int64, s
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return questions, count, nil
|
count, err = r.queries.GetQuestionsAICount(ctx, sqlcgen.GetQuestionsAICountParams{
|
||||||
|
QuizID: quizID,
|
||||||
|
Session: session,
|
||||||
|
})
|
||||||
|
|
||||||
|
return questions, uint64(count), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user