Skip to content

Instantly share code, notes, and snippets.

@durran
Created December 9, 2011 09:40
Show Gist options
  • Save durran/1450910 to your computer and use it in GitHub Desktop.
Save durran/1450910 to your computer and use it in GitHub Desktop.
ML query
# Get the count of notifications for this user
# and this post that need to be sent or have *not*
# been sent in the past 24 hours
User.
where({ _id: user._id, "notifs.post_id" => post_id }).
any_of(
{ "notifs.needs_send" => true },
{ "notifs.last_send" => { '$exists' => false }},
{ "notifs.last_send" => { "$lt" => 1.days.ago.utc }}
).count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment