Skip to content

Commit

Permalink
feat(badge): badge search with page
Browse files Browse the repository at this point in the history
  • Loading branch information
kumfo committed Aug 14, 2024
1 parent cf327f5 commit b0c7675
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/service/badge/badge_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ func (b *BadgeService) ListPaged(ctx context.Context, req *schema.GetBadgeListPa
if err != nil {
return
}
// paged result
count := len(badges)
total = int64(count)
start := (req.Page - 1) * req.PageSize
end := req.Page * req.PageSize
if start >= count {
start = count
end = count
}
if end > count {
end = count
}
badges = badges[start:end]
} else {
req.Query = strings.TrimSpace(strings.TrimLeft(req.Query, "badge:"))
id := uid.DeShortID(req.Query)
Expand Down

0 comments on commit b0c7675

Please sign in to comment.