Skip to content

Instantly share code, notes, and snippets.

@aitor
Forked from mort/Fighting notification flood with the alea gem
Last active January 26, 2017 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aitor/475265 to your computer and use it in GitHub Desktop.
Save aitor/475265 to your computer and use it in GitHub Desktop.
Fighting notification flood with the alea gem
# Activity streams' notifications to third parties are cool because they bring
# a feeling of a shared public space and increase the chance serendipitous findings
# But too much information quickly becomes noise, and relevant bits of news can
# disappear among a tsunami of irrelevant (to me) "x did y with z'
# What we're trying to do here is going from deterministic notifications
# (stuff happens, stuff gets broadcasted) to stochastic ones (stuff happens,
# stuff may gets broadcasted)
# Thanks to the fantastic alea gem (http://github.com/linkingpaths/alea) by Linking Paths,
# the explanation is way longer than this very naive one liner implementation.
# TO-DO: experiment with varying the probabilities based on time thresholds
# (i.e. 100 similar notifications (same type / same originating user) in one hour
# have a 1% chance of showing up, 1 single notification in one hour has 100% chances of showing up)
def do_probabilistic_broadcast
# Always notify you of activity around your stuff
notify_owner
# Don't flood your peers with too much info
maybe(60.percent) { notify_peers }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment