EventIndex: Add a method to gather the currently crawled rooms.
parent
0132c3bbe3
commit
4fe7752f3c
|
@ -33,6 +33,7 @@ export default class EventIndex {
|
|||
// crawl.
|
||||
this._eventsPerCrawl = 100;
|
||||
this._crawler = null;
|
||||
this._currentCheckpoint = null;
|
||||
this.liveEventsForIndex = new Set();
|
||||
}
|
||||
|
||||
|
@ -213,6 +214,8 @@ export default class EventIndex {
|
|||
sleepTime = this._crawlerIdleTime;
|
||||
}
|
||||
|
||||
this._currentCheckpoint = null;
|
||||
|
||||
await sleep(sleepTime);
|
||||
|
||||
console.log("EventIndex: Running the crawler loop.");
|
||||
|
@ -230,6 +233,8 @@ export default class EventIndex {
|
|||
continue;
|
||||
}
|
||||
|
||||
this._currentCheckpoint = checkpoint;
|
||||
|
||||
idle = false;
|
||||
|
||||
console.log("EventIndex: crawling using checkpoint", checkpoint);
|
||||
|
@ -424,4 +429,31 @@ export default class EventIndex {
|
|||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||
return indexManager.indexSize();
|
||||
}
|
||||
|
||||
currentlyCrawledRooms() {
|
||||
let crawlingRooms = new Set();
|
||||
let totalRooms = new Set();
|
||||
|
||||
this.crawlerCheckpoints.forEach((checkpoint, index) => {
|
||||
crawlingRooms.add(checkpoint.roomId);
|
||||
});
|
||||
|
||||
if (this._currentCheckpoint !== null) {
|
||||
crawlingRooms.add(this._currentCheckpoint.roomId);
|
||||
}
|
||||
|
||||
const client = MatrixClientPeg.get();
|
||||
const rooms = client.getRooms();
|
||||
|
||||
const isRoomEncrypted = (room) => {
|
||||
return client.isRoomEncrypted(room.roomId);
|
||||
};
|
||||
|
||||
const encryptedRooms = rooms.filter(isRoomEncrypted);
|
||||
encryptedRooms.forEach((room, index) => {
|
||||
totalRooms.add(room.roomId);
|
||||
});
|
||||
|
||||
return {crawlingRooms, totalRooms}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue