Skip to content

Commit

Permalink
refactor: bump api + refactor pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD committed Mar 13, 2023
1 parent 0cec26e commit efd057d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nuget Be.Vlaanderen.Basisregisters.AggregateSource.Testing.CommandHandling 8.0.0
nuget Be.Vlaanderen.Basisregisters.AggregateSource.Testing.SqlStreamStore.Autofac 8.0.0
nuget Be.Vlaanderen.Basisregisters.AggregateSource.Testing.Xunit 8.0.0

nuget Be.Vlaanderen.Basisregisters.Api 19.1.0
nuget Be.Vlaanderen.Basisregisters.Api 20.0.0

nuget Be.Vlaanderen.Basisregisters.Aws.DistributedMutex 3.0.0

Expand Down
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ NUGET
Be.Vlaanderen.Basisregisters.AggregateSource.Testing (8.0)
Microsoft.Extensions.Logging (>= 6.0)
xunit (>= 2.4.1)
Be.Vlaanderen.Basisregisters.Api (19.1)
Be.Vlaanderen.Basisregisters.Api (20.0)
Autofac (>= 6.3)
Autofac.Extensions.DependencyInjection (>= 7.2)
Be.Vlaanderen.Basisregisters.AggregateSource (>= 7.1.4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public async Task<IActionResult> List(
return Ok(new PostalInformationListResponse
{
PostInfoObjecten = items,
Volgende = BuildNextUri(pagedPostalInformationSet.PaginationInfo, reponseOptions.Value.VolgendeUrl)
Volgende = BuildNextUri(pagedPostalInformationSet.PaginationInfo, items.Count, reponseOptions.Value.VolgendeUrl)
});
}

Expand Down Expand Up @@ -274,12 +274,12 @@ private static async Task<string> BuildAtomFeed(
return sw.ToString();
}

private static Uri? BuildNextUri(PaginationInfo paginationInfo, string nextUrlBase)
private static Uri? BuildNextUri(PaginationInfo paginationInfo, int itemsInCollection, string nextUrlBase)
{
var offset = paginationInfo.Offset;
var limit = paginationInfo.Limit;

return paginationInfo.HasNextPage
return paginationInfo.HasNextPage(itemsInCollection)
? new Uri(string.Format(nextUrlBase, offset + limit, limit))
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public async Task<IActionResult> List(
return Ok(new PostalInformationListOsloResponse
{
PostInfoObjecten = items,
Volgende = BuildNextUri(pagedPostalInformationSet.PaginationInfo, responseOptions.Value.VolgendeUrl),
Volgende = BuildNextUri(pagedPostalInformationSet.PaginationInfo, items.Count, responseOptions.Value.VolgendeUrl),
Context = responseOptions.Value.ContextUrlList
});
}
Expand Down Expand Up @@ -185,12 +185,12 @@ public async Task<IActionResult> Count(
});
}

private static Uri? BuildNextUri(PaginationInfo paginationInfo, string nextUrlBase)
private static Uri? BuildNextUri(PaginationInfo paginationInfo, int itemsInCollection, string nextUrlBase)
{
var offset = paginationInfo.Offset;
var limit = paginationInfo.Limit;

return paginationInfo.HasNextPage
return paginationInfo.HasNextPage(itemsInCollection)
? new Uri(string.Format(nextUrlBase, offset + limit, limit))
: null;
}
Expand Down

0 comments on commit efd057d

Please sign in to comment.