I have a service that fetches data from a target source (not through an API but via scraping) which can change. I want to do pagination so that I return 35 items per page but the target source is 25 items per page. Is there a way where I can convert between these formats so that I keep my pagination even if the target source changes.
Ok, So; I've managed to figure this out. I'll post the solution here for future reference.
recordNumber = pageNumber x itemPerPage
targetPageWithOffset = recordNumber / targetItemPerPage
targetOffset = floor(targetPageWithOffset)
targetPageOffset = targetOffset x targetItemPerPage
for page 3 with 35 itemPerPage when source is 25 ItemPerPage (Page 1 starts from 0)
2 x 35 = 70
70 / 25 = 2.8 (start on page 3 with 0.8 offset)
floor(2.8) = 2
2.8 - 2 = 0.8
0.8 x 25 = 20
= start on target page 3 and offset by 20... collect data until you get to the target amount.