website icon indicating copy to clipboard operation
website copied to clipboard

Add more in app notifications

Open lil5 opened this issue 2 years ago • 14 comments

  • [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

lil5 avatar Jul 27 '23 09:07 lil5

@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

lil5 avatar Jul 27 '23 09:07 lil5

sure thing!

ghost avatar Jul 27 '23 09:07 ghost

Awesome! for code references/example find the flow for Somebody holds a bag for longer than 7 days

lil5 avatar Jul 27 '23 09:07 lil5

@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

ghost avatar Jul 30 '23 19:07 ghost

@tobifaf https://github.com/the-clothing-loop/website/blob/main/server/internal/controllers/cron.go see the hourly cron

lil5 avatar Jul 31 '23 08:07 lil5

as discussed and tested, the "A new bulky item is added priority" is already working

ghost avatar Aug 07 '23 15:08 ghost

Somebody else set you to a bag is fixed here: https://github.com/the-clothing-loop/website/pull/584

lil5 avatar Aug 29 '23 08:08 lil5

@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

ghost avatar Aug 30 '23 21:08 ghost

@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 avatar Aug 31 '23 16:08 lil5

@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?

ghost avatar Sep 01 '23 05:09 ghost

@tobifaf Before coding could you please create a mermaid document explaining what/how you want it to work.

lil5 avatar Sep 01 '23 07:09 lil5

sure thing!

ghost avatar Sep 01 '23 07:09 ghost

@lil5 can you have a look at #658 ? This is my proposal for the debounced notification system.

ghost avatar Dec 07 '23 09:12 ghost

@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.

ghost avatar Dec 18 '23 16:12 ghost