Question: add a pagination limit to the usecase.Fetch method
This commit is contained in:
parent
300709f527
commit
5dd92c0665
|
@ -1,6 +1,6 @@
|
|||
package question
|
||||
|
||||
const (
|
||||
DefaultLimit = 100
|
||||
TestMaxLimit = 40
|
||||
FetchMaxLimit = 500
|
||||
TestMaxLimit = 40
|
||||
)
|
||||
|
|
|
@ -67,10 +67,13 @@ func (ucase *usecase) Delete(ctx context.Context, f *models.QuestionFilter) ([]*
|
|||
func (ucase *usecase) Fetch(ctx context.Context, cfg *question.FetchConfig) ([]*models.Question, int, error) {
|
||||
if cfg == nil {
|
||||
cfg = &question.FetchConfig{
|
||||
Limit: question.DefaultLimit,
|
||||
Limit: question.FetchMaxLimit,
|
||||
Count: true,
|
||||
}
|
||||
}
|
||||
if cfg.Limit > question.FetchMaxLimit {
|
||||
cfg.Limit = question.FetchMaxLimit
|
||||
}
|
||||
cfg.Sort = sqlutils.SanitizeSorts(cfg.Sort)
|
||||
return ucase.questionRepository.Fetch(ctx, cfg)
|
||||
}
|
||||
|
|
Reference in New Issue