You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently developing a home booking system where a Home has_many Rate. Each Rate has a price and a date. Occasionally, hundreds of Rate entries for a given Home are updated at once. When this happens, I need to refresh the Home’s monthly average price, which is a resource-intensive operation.
To handle this, I enqueue a CalculateMonthlyPriceJob using an after_update callback on Rate. While this works well, it results in n jobs being enqueued (if nRate records have been updated).
What I'd like to do is debounce these jobs so that only one job is executed, and run 5 seconds after the last Rate update.
How can I achieve this using sidekiq-unique-jobs ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone 👋
I'm currently developing a home booking system where a
Home
has_manyRate
. EachRate
has a price and a date. Occasionally, hundreds ofRate
entries for a givenHome
are updated at once. When this happens, I need to refresh theHome
’s monthly average price, which is a resource-intensive operation.To handle this, I enqueue a
CalculateMonthlyPriceJob
using anafter_update
callback onRate
. While this works well, it results inn
jobs being enqueued (ifn
Rate
records have been updated).What I'd like to do is debounce these jobs so that only one job is executed, and run 5 seconds after the last
Rate
update.How can I achieve this using
sidekiq-unique-jobs
?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions