KiOui / TOSTI

Tartarus Order System for Take-away Items
https://tosti.science.ru.nl/
MIT License
10 stars 1 forks source link

Group orders per user #529

Open mark-boute opened 10 months ago

mark-boute commented 10 months ago

Group orders based on users and sort queue based on the first order time. This would remove the case where someone is clicking their Tosti at the same speed my grandpa uses his phone results in a lot of in-between orders. This simulates the old-fashioned method of serving customers customer at a time.

1a          1a
2a    ===>  1b
2b          2a
1b          2b
JobDoesburg commented 10 months ago

The current behavior is intended and @KiOui and I actually discussed it a lot (considering both the intended behavior but also the maintainability and elegance of the software).

I think this could cause some unwanted edge cases if there is a large delay between the orders. What should happen if there's 15 minutes in-between the orders?

I agree that you might want to do this, but only for a 1 minute window or something.

mark-boute commented 10 months ago

For a x-minute window I think we'll need a separate sort function. If you don't mind that extra layer of complexity that would be the nicest solution indeed.

mark-boute commented 10 months ago

https://github.com/KiOui/TOSTI/blob/eea789964266e38dd62fbb4e18438b6b2f345f28/website/orders/api/v1/views.py#L50C1-L56C10

@JobDoesburg I think this order_by should be changed, is that assumption correct?

JobDoesburg commented 10 months ago

Yes so it seems. You probably want to group on user and sort on the min order time of each group. But only group if the order times are at most x minutes apart, the latter of which I wouldn't directly know how to implement

KiOui commented 10 months ago

I would maybe even go as far and just implement this in the javascript on the frontend.

JobDoesburg commented 10 months ago

I would maybe even go as far and just implement this in the javascript on the frontend.

Noooooooo

mark-boute commented 10 months ago

I would maybe even go as far and just implement this in the javascript on the frontend.

I think you want to stay as close as possible to the source of truth here, hence change it right where that truth is generated