mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-12-16 06:15:29 +00:00
BUGFIX: Paginierung Bände
This commit is contained in:
@@ -255,7 +255,7 @@ func NewSearchBeitraege(app core.App, params SearchParameters, filters Beitraege
|
||||
hits = append(hits, e.Id)
|
||||
}
|
||||
|
||||
pages := PagesEntries(hits, contentsmap, DEFAULT_PAGESIZE)
|
||||
pages := PagesMap(hits, contentsmap, DEFAULT_PAGESIZE)
|
||||
if params.Page < 1 || params.Page > len(pages) {
|
||||
params.Page = 1
|
||||
}
|
||||
@@ -304,7 +304,7 @@ func (p *SearchResultBeitraege) PagesCount() int {
|
||||
return len(p.Pages) - 1
|
||||
}
|
||||
|
||||
func PagesEntries[T any](hits []string, hitmap map[string][]*T, pagesize int) []int {
|
||||
func PagesMap[T any](hits []string, hitmap map[string][]*T, pagesize int) []int {
|
||||
ret := []int{0}
|
||||
m := 0
|
||||
for i, hit := range hits {
|
||||
@@ -321,3 +321,21 @@ func PagesEntries[T any](hits []string, hitmap map[string][]*T, pagesize int) []
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func PagesArray[T any](hits []T, pagesize int) []int {
|
||||
ret := []int{0}
|
||||
m := 0
|
||||
for i := range hits {
|
||||
m++
|
||||
if m >= pagesize {
|
||||
ret = append(ret, i)
|
||||
m = 0
|
||||
}
|
||||
}
|
||||
|
||||
if m > 0 {
|
||||
ret = append(ret, len(hits))
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user