ircd:Ⓜ️:user::rooms: Add prefetch loop.

This commit is contained in:
Jason Volk 2022-08-19 16:17:48 -07:00
parent df6d463623
commit 04559a28f6
2 changed files with 33 additions and 0 deletions

View File

@ -33,6 +33,8 @@ struct ircd::m::user::rooms
size_t count(const string_view &membership) const;
size_t count() const;
bool prefetch() const;
rooms(const m::user &user)
:user{user}
{}

View File

@ -8,6 +8,37 @@
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
bool
ircd::m::user::rooms::prefetch()
const
{
const m::events::state::tuple query
{
user,
"m.room.member"_sv,
m::room::id{},
-1L,
0UL
};
bool ret{false};
return m::events::state::for_each(query, [this, &ret]
(const auto &tuple)
{
const auto &[state_key, type, room_id, depth, event_idx]
{
tuple
};
assert(type == "m.room.member");
assert(state_key == user);
ret |= m::membership_prefetch(event_idx);
return true;
});
return ret;
}
size_t
ircd::m::user::rooms::count()
const