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,
|
||||
CreatedAt: row.Createdat,
|
||||
}
|
||||
count = row.TotalCount
|
||||
|
||||
users = append(users, user)
|
||||
}
|
||||
|
||||
count, err = r.queries.GetUsersCount(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := model.UserListResp{
|
||||
Count: count,
|
||||
Items: users,
|
||||
@ -299,7 +303,6 @@ func (r *AmoRepository) GetPipelinesWithPagination(ctx context.Context, req *mod
|
||||
var pipelines []model.Pipeline
|
||||
|
||||
for _, row := range rows {
|
||||
count = row.TotalCount
|
||||
pipeline := model.Pipeline{
|
||||
ID: row.ID,
|
||||
Amoid: row.Amoid,
|
||||
@ -311,6 +314,11 @@ func (r *AmoRepository) GetPipelinesWithPagination(ctx context.Context, req *mod
|
||||
pipelines = append(pipelines, pipeline)
|
||||
}
|
||||
|
||||
count, err = r.queries.GetPipelinesCount(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := model.UserListPipelinesResp{
|
||||
Count: count,
|
||||
Items: pipelines,
|
||||
@ -400,7 +408,6 @@ func (r *AmoRepository) GetStepsWithPagination(ctx context.Context, req *model.P
|
||||
var steps []model.Step
|
||||
|
||||
for _, row := range rows {
|
||||
count = row.TotalCount
|
||||
step := model.Step{
|
||||
ID: row.ID,
|
||||
Amoid: row.Amoid,
|
||||
@ -413,6 +420,14 @@ func (r *AmoRepository) GetStepsWithPagination(ctx context.Context, req *model.P
|
||||
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{
|
||||
Count: count,
|
||||
Items: steps,
|
||||
@ -505,8 +520,6 @@ func (r *AmoRepository) GetTagsWithPagination(ctx context.Context, req *model.Pa
|
||||
var count int64
|
||||
var tags []model.Tag
|
||||
for _, row := range rows {
|
||||
count = row.TotalCount
|
||||
|
||||
var entity model.EntityType
|
||||
v := string(row.Entity.([]byte))
|
||||
entity = model.EntityType(v)
|
||||
@ -523,6 +536,11 @@ func (r *AmoRepository) GetTagsWithPagination(ctx context.Context, req *model.Pa
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
|
||||
count, err = r.queries.GetTagsCount(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := model.UserListTagsResp{
|
||||
Count: count,
|
||||
Items: tags,
|
||||
@ -625,8 +643,6 @@ func (r *AmoRepository) GetFieldsWithPagination(ctx context.Context, req *model.
|
||||
var fields []model.Field
|
||||
|
||||
for _, row := range rows {
|
||||
count = row.TotalCount
|
||||
|
||||
var entity model.EntityType
|
||||
v := string(row.Entity.([]byte))
|
||||
entity = model.EntityType(v)
|
||||
@ -649,6 +665,11 @@ func (r *AmoRepository) GetFieldsWithPagination(ctx context.Context, req *model.
|
||||
fields = append(fields, field)
|
||||
}
|
||||
|
||||
count, err = r.queries.GetFieldsCount(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := model.UserListFieldsResp{
|
||||
Count: count,
|
||||
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) {
|
||||
row, err := r.queries.GetQuizRule(ctx, sqlcgen.GetQuizRuleParams{
|
||||
Quizid: int32(quizID),
|
||||
Quizid: int32(quizID),
|
||||
Accountid: accountID,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/lib/pq"
|
||||
"gitea.pena/SQuiz/common/dal/sqlcgen"
|
||||
"gitea.pena/SQuiz/common/model"
|
||||
"github.com/lib/pq"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -160,7 +160,7 @@ func (r *QuestionRepository) GetQuestionList(
|
||||
&pIds,
|
||||
&piece.CreatedAt,
|
||||
&piece.UpdatedAt,
|
||||
&piece.Session,
|
||||
&piece.Session,
|
||||
); err != nil {
|
||||
qerr = err
|
||||
return
|
||||
@ -500,11 +500,9 @@ func (r *QuestionRepository) GetQuestionsAI(ctx context.Context, quizID int64, s
|
||||
}
|
||||
|
||||
var questions []model.Question
|
||||
var count uint64
|
||||
var count int64
|
||||
|
||||
for _, row := range rows {
|
||||
count = uint64(row.Count)
|
||||
|
||||
questions = append(questions, model.Question{
|
||||
Id: uint64(row.ID),
|
||||
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