openfoodfacts / openfoodfacts-dart

Open Food Facts API Wrapper
https://pub.dev/packages/openfoodfacts
Apache License 2.0
167 stars 67 forks source link

Add `start_with_offset` parameter in requests for products #697

Open im-trisha opened 1 year ago

im-trisha commented 1 year ago

Why - Problem description

i'm implementing kind of a pagination in my application. well, kinda, so i have to use an offset, for example: i first request 10 foods with the search term 'nute', using PageSize(10), then, i want 20 other elements, but this time i obviously have to skip the first 10 this could be simply achieved by PageSize(20) and start_offset: 10 in the request query

What - Proposed solution

well, add a start_offset parameter and (Like PageOffset(10)) NOTE: I'm asking this because i can't manage to find anything in this dart wrapper, thus, if i've understood right the OFF api has a start_offset parameter.

Alternatives you've considered

this would obviously be simple, i just make 2 request with PageSize(10), the first with Page(1) and the second with Page(2) but, i have to make 2 request, or make a request asking 20+10,

monsieurtanuki commented 1 year ago

Hi @GiuseppeFn! Obviously you understand both parameters page and page_size, but your need is slightly more refined, as you want to start at the nth product regardless of the page size, right?

@alexgarel @stephanegigandet Is there a parameter like start_offset, something like start_offset=7&page_size=10 that would make it possible to get the products from 7 to 16?

im-trisha commented 1 year ago

Hi @monsieurtanuki, that's exaclty what i was trying to achieve

stephanegigandet commented 1 year ago

Hi, we don't have that today, but we could add something like that in a future version of the search API.

im-trisha commented 1 year ago

This would be great! Please notice me if anything changes :) @stephanegigandet