EventIndex: Add a method to gather the currently crawled rooms.
This commit is contained in:
parent
0132c3bbe3
commit
4fe7752f3c
1 changed files with 32 additions and 0 deletions
|
@ -33,6 +33,7 @@ export default class EventIndex {
|
||||||
// crawl.
|
// crawl.
|
||||||
this._eventsPerCrawl = 100;
|
this._eventsPerCrawl = 100;
|
||||||
this._crawler = null;
|
this._crawler = null;
|
||||||
|
this._currentCheckpoint = null;
|
||||||
this.liveEventsForIndex = new Set();
|
this.liveEventsForIndex = new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +214,8 @@ export default class EventIndex {
|
||||||
sleepTime = this._crawlerIdleTime;
|
sleepTime = this._crawlerIdleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._currentCheckpoint = null;
|
||||||
|
|
||||||
await sleep(sleepTime);
|
await sleep(sleepTime);
|
||||||
|
|
||||||
console.log("EventIndex: Running the crawler loop.");
|
console.log("EventIndex: Running the crawler loop.");
|
||||||
|
@ -230,6 +233,8 @@ export default class EventIndex {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._currentCheckpoint = checkpoint;
|
||||||
|
|
||||||
idle = false;
|
idle = false;
|
||||||
|
|
||||||
console.log("EventIndex: crawling using checkpoint", checkpoint);
|
console.log("EventIndex: crawling using checkpoint", checkpoint);
|
||||||
|
@ -424,4 +429,31 @@ export default class EventIndex {
|
||||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||||
return indexManager.indexSize();
|
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…
Add table
Add a link
Reference in a new issue