Skip to content

Commit 0e800c6

Browse files
authored
Merge pull request #263 from AtlasOfLivingAustralia/252-paging-for-distributions
#252 add paging for distributions
2 parents a3d6ecf + 366cdd9 commit 0e800c6

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

grails-app/controllers/au/org/ala/spatial/ChecklistController.groovy

+14
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ class ChecklistController {
7575
schema = @Schema(implementation = String),
7676
description = "Object ID to filter",
7777
required = false
78+
),
79+
@Parameter(
80+
name = "start",
81+
in = QUERY,
82+
schema = @Schema(implementation = String),
83+
description = "Starting index for pagination",
84+
required = false
85+
),
86+
@Parameter(
87+
name = "pageSize",
88+
in = QUERY,
89+
schema = @Schema(implementation = String),
90+
description = "Page size for pagination",
91+
required = false
7892
)
7993
],
8094
responses = [

grails-app/controllers/au/org/ala/spatial/DistributionController.groovy

+14
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ class DistributionController {
7777
schema = @Schema(implementation = String),
7878
description = "Object ID to filter",
7979
required = false
80+
),
81+
@Parameter(
82+
name = "start",
83+
in = QUERY,
84+
schema = @Schema(implementation = String),
85+
description = "Starting index for pagination",
86+
required = false
87+
),
88+
@Parameter(
89+
name = "pageSize",
90+
in = QUERY,
91+
schema = @Schema(implementation = String),
92+
description = "Page size for pagination",
93+
required = false
8094
)
8195
],
8296
responses = [

grails-app/controllers/au/org/ala/spatial/TrackController.groovy

+14
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ class TrackController {
7676
schema = @Schema(implementation = String),
7777
description = "Object ID to filter",
7878
required = false
79+
),
80+
@Parameter(
81+
name = "start",
82+
in = QUERY,
83+
schema = @Schema(implementation = String),
84+
description = "Starting index for pagination",
85+
required = false
86+
),
87+
@Parameter(
88+
name = "pageSize",
89+
in = QUERY,
90+
schema = @Schema(implementation = String),
91+
description = "Page size for pagination",
92+
required = false
7993
)
8094
],
8195
responses = [

grails-app/services/au/org/ala/spatial/DistributionsService.groovy

+7
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ class DistributionsService {
123123
sql += " WHERE " + whereClause.toString()
124124
}
125125

126+
if (queryParams.pageSize) {
127+
int start = queryParams.start as Integer ?: 0
128+
sql += " LIMIT :pageSize OFFSET :offset"
129+
params.put("pageSize", queryParams.pageSize as Integer)
130+
params.put("offset", start)
131+
}
132+
126133
List result = new ArrayList()
127134

128135
String[] fields = SELECT_CLAUSE.split(',')

0 commit comments

Comments
 (0)