Skip to content

Commit

Permalink
fix(repos): fix repos pagination (close #472)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Jan 4, 2021
1 parent 392b75c commit 2c0c5f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions server/store/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ func (s repositoryStore) List(filters core.RepositoryFilter) ([]core.Repository,
Or("team_users.user_id = ? AND permissions.read = ? AND repositories.full_name LIKE ?", filters.UserID, true, keyword)
}

if filters.Limit != 0 && filters.Offset != 0 {
db = db.Limit(filters.Limit).Offset(filters.Offset)
if filters.Limit != 0 {
db = db.Limit(filters.Limit)
}

err = db.Order("active desc, name asc").Group("repositories.id").Find(&repos).Count(&count).Error
if filters.Offset != 0 {
db = db.Offset(filters.Offset)
}

err = db.Order("active desc, name asc").Group("repositories.id").Find(&repos).Limit(-1).Count(&count).Error
if err != nil || count == 0 {
return repos, count, err
}
Expand Down
3 changes: 2 additions & 1 deletion web/abstruse/src/app/repos/repos/repos.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ <h2>My Repositories</h2>
*ngFor="let p of pages"
(click)="setPage(p)"
[class.is-active]="page === p"
>{{ p }}</span
>
{{ p }}
</span>
<span class="btn" (click)="next()">Next</span>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions web/abstruse/src/styles/pagination.sass
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
color: $text-primary
border: 1px solid $gray

&.is-hidden
display: none

.btn
padding: 5px 10px
margin: 0 5px
Expand Down

0 comments on commit 2c0c5f3

Please # to comment.