Skip to content

Commit 15b40fc

Browse files
refactor(client): handling of absent pagination total
1 parent 9873736 commit 15b40fc

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ private constructor(
4343
}
4444

4545
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
46-
val totalCount =
47-
paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE)
48-
return offset + items().size < totalCount
46+
val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull()
47+
return totalCount == null || offset + items().size < totalCount
4948
}
5049

5150
fun nextPageParams(): HrisDirectoryListIndividualsParams {

finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ private constructor(
4646
}
4747

4848
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
49-
val totalCount =
50-
paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE)
51-
return offset + items().size < totalCount
49+
val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull()
50+
return totalCount == null || offset + items().size < totalCount
5251
}
5352

5453
fun nextPageParams(): HrisDirectoryListIndividualsParams {

finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ private constructor(
4242
}
4343

4444
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
45-
val totalCount =
46-
paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE)
47-
return offset + items().size < totalCount
45+
val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull()
46+
return totalCount == null || offset + items().size < totalCount
4847
}
4948

5049
fun nextPageParams(): HrisDirectoryListParams {

finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ private constructor(
4545
}
4646

4747
val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0)
48-
val totalCount =
49-
paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE)
50-
return offset + items().size < totalCount
48+
val totalCount = paging().flatMap { it._count().getOptional("count") }.getOrNull()
49+
return totalCount == null || offset + items().size < totalCount
5150
}
5251

5352
fun nextPageParams(): HrisDirectoryListParams {

0 commit comments

Comments
 (0)