Add more in app notifications
- [x] Somebody holds a bag for longer than 7 days
- [x] A new bulky item is added priority
- [ ] There is a significant route change: somebody within 2 before or 2 after has been changed
- [x] Somebody else set you to a bag
@tobifaf If you interested?
Start off with finishing off A new bulky item is added, create a PR for that, then we call look at the others in this list
sure thing!
Awesome! for code references/example find the flow for Somebody holds a bag for longer than 7 days
@lil5 What exactly do you mean with that flow? I could only find: https://github.com/the-clothing-loop/website/blob/60fbd78fe2fea9f4119c82f172cd726b2581edb0/app/src/pages/BagsList.tsx#L341C23-L341C23
@tobifaf https://github.com/the-clothing-loop/website/blob/main/server/internal/controllers/cron.go see the hourly cron
as discussed and tested, the "A new bulky item is added priority" is already working
Somebody else set you to a bag is fixed here: https://github.com/the-clothing-loop/website/pull/584
@lil5 can you have a look at this proposal for making sure users are not getting alot of the same notifications? https://github.com/the-clothing-loop/website/commit/bef9e99c9dca33c06ce023c824182cb9713f9de8
@tobifaf good idea, there are no in memory hashmap packages (think redis but living in the go runtime), we could use for a more global approach?
maybe something like this may help? https://github.com/orcaman/concurrent-map
@lil5, concurrent-map seems a nice and simple solution. Do you prefer to have this as sort of a more generic "key/value in-application" db?
@tobifaf Before coding could you please create a mermaid document explaining what/how you want it to work.
sure thing!
@lil5 can you have a look at #658 ? This is my proposal for the debounced notification system.
@lil5 i was looking at SetRouteOrderByUserUIDs in models/chain.go, since that's triggered on every route change. The proposed SQL is something like:
users := []User{}
tx.Exec(SELECT users.* FROM user_chains LEFT JOIN users ON users.id = user_chains.user_id WHERE user_chains.chain_id = ? AND user_chains.route_order BETWEEN ? AND ?, c.ID, i-2, i+2).Scan(&users)
But this does not take into account:
- changes at the start of the loop should also include the last one or two users at the end of the loop.
- the same but for changes at the end of the loop
- sometimes the route_order is missing entries (for example: 1,2,4,5,6 is missing the 3). In this case not every user that should be notified is triggered.
If a user is removed from the loop, this is also not triggered. So that needs a different implementation.