Add upper-bound for presence_since().

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-26 04:59:00 +00:00
parent c6836e51b2
commit 63dfe8f7e3
5 changed files with 18 additions and 10 deletions

View File

@@ -154,13 +154,15 @@ impl Data {
pub(super) fn presence_since(
&self,
since: u64,
to: Option<u64>,
) -> impl Stream<Item = (&UserId, u64, &[u8])> + Send + '_ {
self.presenceid_presence
.raw_stream()
.ignore_err()
.ready_filter_map(move |(key, presence)| {
let (count, user_id) = presenceid_parse(key).ok()?;
(count > since).then_some((user_id, count, presence))
(count > since && to.is_none_or(|to| count <= to))
.then_some((user_id, count, presence))
})
}
}

View File

@@ -239,8 +239,9 @@ impl Service {
pub fn presence_since(
&self,
since: u64,
to: Option<u64>,
) -> impl Stream<Item = (&UserId, u64, &[u8])> + Send + '_ {
self.db.presence_since(since)
self.db.presence_since(since, to)
}
#[inline]