hybrid pagination
This commit is contained in:
@@ -152,7 +152,7 @@ func (s *feedbackService) Get(ctx context.Context, id string) (*FeedbackResponse
|
||||
}
|
||||
|
||||
func (s *feedbackService) Search(ctx context.Context, criteria SearchForm, pagination *response.Pagination) (*FeedbackListResponse, error) {
|
||||
feedbacks, total, err := s.feedbackRepo.Search(ctx, criteria, pagination)
|
||||
page, err := s.feedbackRepo.Search(ctx, criteria, pagination)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to list feedback", map[string]interface{}{
|
||||
"criteria": criteria,
|
||||
@@ -163,16 +163,10 @@ func (s *feedbackService) Search(ctx context.Context, criteria SearchForm, pagin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
meta := &response.Meta{
|
||||
Total: int(total),
|
||||
Limit: pagination.Limit,
|
||||
Offset: pagination.Offset,
|
||||
Page: (pagination.Offset / pagination.Limit) + 1,
|
||||
Pages: int((total + int64(pagination.Limit) - 1) / int64(pagination.Limit)),
|
||||
}
|
||||
meta := pagination.ListMeta(page.TotalCount, page.NextCursor, page.HasMore, page.PageOffset)
|
||||
|
||||
result := make([]*FeedbackResponse, len(feedbacks))
|
||||
for i, feedback := range feedbacks {
|
||||
result := make([]*FeedbackResponse, len(page.Items))
|
||||
for i, feedback := range page.Items {
|
||||
tender, company, _ := s.getDetails(ctx, feedback.TenderID, *feedback.CompanyID)
|
||||
result[i] = feedback.ToResponse(tender, company)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user