Fix bug from roomuserid_knockedcount vs. roomid_knockedcount.

The use of "count" instead of "sequence" leads to confusion with
i.e. counting the elements of a set e.g. Iterator::count().

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-25 13:15:42 +00:00
parent 7bdd4065c8
commit 22ef704ac6
3 changed files with 29 additions and 12 deletions

View File

@@ -141,6 +141,10 @@ pub(super) static MAPS: &[Descriptor] = &[
name: "referencedevents",
..descriptor::RANDOM
},
Descriptor {
name: "roomid_knockedcount",
..descriptor::RANDOM_SMALL
},
Descriptor {
name: "roomid_invitedcount",
..descriptor::RANDOM_SMALL

View File

@@ -38,6 +38,7 @@ struct Services {
}
struct Data {
roomid_knockedcount: Arc<Map>,
roomid_invitedcount: Arc<Map>,
roomid_inviteviaservers: Arc<Map>,
roomid_joinedcount: Arc<Map>,
@@ -72,6 +73,7 @@ impl crate::Service for Service {
users: args.depend::<users::Service>("users"),
},
db: Data {
roomid_knockedcount: args.db["roomid_knockedcount"].clone(),
roomid_invitedcount: args.db["roomid_invitedcount"].clone(),
roomid_inviteviaservers: args.db["roomid_inviteviaservers"].clone(),
roomid_joinedcount: args.db["roomid_joinedcount"].clone(),
@@ -249,6 +251,28 @@ pub async fn room_joined_count(&self, room_id: &RoomId) -> Result<u64> {
.deserialized()
}
/// Returns the number of users which are currently invited to a room
#[implement(Service)]
#[tracing::instrument(skip(self), level = "trace")]
pub async fn room_invited_count(&self, room_id: &RoomId) -> Result<u64> {
self.db
.roomid_invitedcount
.get(room_id)
.await
.deserialized()
}
/// Returns the number of users which are currently knocking upon a room
#[implement(Service)]
#[tracing::instrument(skip(self), level = "trace")]
pub async fn room_knocked_count(&self, room_id: &RoomId) -> Result<u64> {
self.db
.roomid_knockedcount
.get(room_id)
.await
.deserialized()
}
#[implement(Service)]
#[tracing::instrument(skip(self), level = "debug")]
/// Returns an iterator of all our local users in the room, even if they're
@@ -273,17 +297,6 @@ pub fn active_local_users_in_room<'a>(
.filter(|user| self.services.users.is_active(user))
}
/// Returns the number of users which are currently invited to a room
#[implement(Service)]
#[tracing::instrument(skip(self), level = "trace")]
pub async fn room_invited_count(&self, room_id: &RoomId) -> Result<u64> {
self.db
.roomid_invitedcount
.get(room_id)
.await
.deserialized()
}
/// Returns an iterator over all User IDs who ever joined a room.
#[implement(Service)]
#[tracing::instrument(skip(self), level = "debug")]

View File

@@ -198,7 +198,7 @@ pub async fn update_joined_count(&self, room_id: &RoomId) {
.roomid_invitedcount
.raw_put(room_id, invitedcount);
self.db
.roomuserid_knockedcount
.roomid_knockedcount
.raw_put(room_id, knockedcount);
self.room_servers(room_id)