Hi,
I’m working on a booking system which I’ve mentioned in another topic. It relies to an external and most of the time a bit archaic API, where I get the availability of an item in this format:
{
"item_id": 1602,
"year": 2020,
"as": "111111111100000000000000011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111100000000000000000000000000000000000111111111111111111111000000011111110000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
So:
- Every char on the
as
string represents a day for theyear
-
as
is always 365 or 366 (leap year) chars long. -
0
means available,1
means booked.
When I receive a query with a date range, it means translating those days to a start position, and length, and looking for a substring of 0
s starting at that position.
For example, if the user is looking for available items between 10th Jan (index:9) and 15th Jan (length:6), the pseudocode I’d have would be similar to:
Filter(
Paginate(Match(Index('availability'))),
Lambda(['as', 'ref'], Equals(SubStr(Var('as'), 9, 6), "000000")
)
The catch is I have around 10.000 of those items per year and I’m planning to keep current and next year’s availability information which accounts for around 20.000 records. The above approach wouldn’t work as I’d get lots of pages with 2 or 3 items.
I’ve searched through the forum, and StackOverflow, and they were really good answers to similar questions, mostly on using Ngrams
and custom binding for indexes. I believe, -although perfectly happy to be corrected, my use case is different from what has been suggested.
Am I missing anything obvious here?