0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

modules: Move room::events::horizon::rebuild() to m_room_events.so.

This commit is contained in:
Jason Volk 2019-09-19 11:08:59 -07:00
parent 6b69fe2d24
commit d4b0dbaa8c
2 changed files with 46 additions and 39 deletions

View file

@ -204,42 +204,3 @@ ircd::m::event::horizon::rebuild()
txn();
return ret;
}
size_t
ircd::m::room::events::horizon::rebuild()
{
m::dbs::write_opts opts;
opts.appendix.reset();
opts.appendix.set(dbs::appendix::EVENT_HORIZON);
db::txn txn
{
*dbs::events
};
size_t ret(0);
m::room::events it
{
room
};
for(; it; --it)
{
const m::event &event{*it};
const event::prev prev_events{event};
opts.event_idx = it.event_idx();
m::for_each(prev_events, [&]
(const m::event::id &event_id)
{
if(m::exists(event_id))
return true;
m::dbs::_index_event_horizon(txn, event, opts, event_id);
++ret;
return true;
});
}
txn();
return ret;
}

View file

@ -340,6 +340,52 @@ const
// room::events::horizon
//
//TODO: XXX remove fwd decl
namespace ircd::m::dbs
{
void _index_event_horizon(db::txn &, const event &, const write_opts &, const m::event::id &);
}
size_t
IRCD_MODULE_EXPORT
ircd::m::room::events::horizon::rebuild()
{
m::dbs::write_opts opts;
opts.appendix.reset();
opts.appendix.set(dbs::appendix::EVENT_HORIZON);
db::txn txn
{
*dbs::events
};
size_t ret(0);
m::room::events it
{
room
};
for(; it; --it)
{
const m::event &event{*it};
const event::prev prev_events{event};
opts.event_idx = it.event_idx();
m::for_each(prev_events, [&]
(const m::event::id &event_id)
{
if(m::exists(event_id))
return true;
m::dbs::_index_event_horizon(txn, event, opts, event_id);
++ret;
return true;
});
}
txn();
return ret;
}
size_t
IRCD_MODULE_EXPORT
ircd::m::room::events::horizon::count()