Skip to content

Commit 1151b35

Browse files
committed
Fix pagination links inside relation data
1 parent 3456ef9 commit 1151b35

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

relationships/r_foreignkey_reverse.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package relationships
22

33
import (
44
"errors"
5+
"math"
56
"fmt"
67
"github.com/bor3ham/reja/schema"
78
"github.com/bor3ham/reja/utils"
@@ -135,7 +136,7 @@ func (fkr ForeignKeyReverse) GetValues(
135136
}
136137
value.Links = utils.GetPaginationLinks(
137138
relationLink(c, m.Type, id, fkr.Key),
138-
1,
139+
int(math.Floor(float64(offset / pageSize))) + 1,
139140
pageSize,
140141
server.GetDefaultDirectPageSize(),
141142
total,

relationships/r_genericforeignkey_reverse.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package relationships
22

33
import (
44
"errors"
5+
"math"
56
"fmt"
67
"github.com/bor3ham/reja/schema"
78
"github.com/bor3ham/reja/utils"
@@ -139,7 +140,7 @@ func (gfkr GenericForeignKeyReverse) GetValues(
139140
}
140141
value.Links = utils.GetPaginationLinks(
141142
relationLink(c, m.Type, id, gfkr.Key),
142-
1,
143+
int(math.Floor(float64(offset / pageSize))) + 1,
143144
pageSize,
144145
server.GetDefaultDirectPageSize(),
145146
total,

relationships/r_manytomany.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package relationships
22

33
import (
44
"errors"
5+
"math"
56
"fmt"
67
"github.com/bor3ham/reja/schema"
78
"github.com/bor3ham/reja/utils"
@@ -183,7 +184,7 @@ func (m2m ManyToMany) GetValues(
183184
}
184185
value.Links = utils.GetPaginationLinks(
185186
relationLink(c, m.Type, id, m2m.Key),
186-
1,
187+
int(math.Floor(float64(offset / pageSize))) + 1,
187188
pageSize,
188189
server.GetDefaultDirectPageSize(),
189190
total,

0 commit comments

Comments
 (0)