Merge pull request #4022 from matrix-org/poljar/eventindex-roomcount

ManageEventIndexDialog: Show how many rooms are being currently crawled.
This commit is contained in:
Matthew Hodgson 2020-02-01 12:18:44 +01:00 committed by GitHub
commit 4c426faedc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 3 deletions

View file

@ -38,6 +38,7 @@ export default class ManageEventIndexDialog extends React.Component {
this.state = { this.state = {
eventIndexSize: 0, eventIndexSize: 0,
eventCount: 0, eventCount: 0,
crawlingRoomsCount: 0,
roomCount: 0, roomCount: 0,
currentRoom: null, currentRoom: null,
crawlerSleepTime: crawlerSleepTime:
@ -51,11 +52,15 @@ export default class ManageEventIndexDialog extends React.Component {
let currentRoom = null; let currentRoom = null;
if (room) currentRoom = room.name; if (room) currentRoom = room.name;
const roomStats = eventIndex.crawlingRooms();
const crawlingRoomsCount = roomStats.crawlingRooms.size;
const roomCount = roomStats.totalRooms.size;
this.setState({ this.setState({
eventIndexSize: stats.size, eventIndexSize: stats.size,
roomCount: stats.roomCount,
eventCount: stats.eventCount, eventCount: stats.eventCount,
crawlingRoomsCount: crawlingRoomsCount,
roomCount: roomCount,
currentRoom: currentRoom, currentRoom: currentRoom,
}); });
} }
@ -70,6 +75,7 @@ export default class ManageEventIndexDialog extends React.Component {
async componentWillMount(): void { async componentWillMount(): void {
let eventIndexSize = 0; let eventIndexSize = 0;
let crawlingRoomsCount = 0;
let roomCount = 0; let roomCount = 0;
let eventCount = 0; let eventCount = 0;
let currentRoom = null; let currentRoom = null;
@ -80,8 +86,10 @@ export default class ManageEventIndexDialog extends React.Component {
eventIndex.on("changedCheckpoint", this.updateCurrentRoom.bind(this)); eventIndex.on("changedCheckpoint", this.updateCurrentRoom.bind(this));
const stats = await eventIndex.getStats(); const stats = await eventIndex.getStats();
const roomStats = eventIndex.crawlingRooms();
eventIndexSize = stats.size; eventIndexSize = stats.size;
roomCount = stats.roomCount; crawlingRoomsCount = roomStats.crawlingRooms.size;
roomCount = roomStats.totalRooms.size;
eventCount = stats.eventCount; eventCount = stats.eventCount;
const room = eventIndex.currentRoom(); const room = eventIndex.currentRoom();
@ -91,6 +99,7 @@ export default class ManageEventIndexDialog extends React.Component {
this.setState({ this.setState({
eventIndexSize, eventIndexSize,
eventCount, eventCount,
crawlingRoomsCount,
roomCount, roomCount,
currentRoom, currentRoom,
}); });
@ -135,7 +144,8 @@ export default class ManageEventIndexDialog extends React.Component {
<div className='mx_SettingsTab_subsectionText'> <div className='mx_SettingsTab_subsectionText'>
{_t("Space used:")} {formatBytes(this.state.eventIndexSize, 0)}<br /> {_t("Space used:")} {formatBytes(this.state.eventIndexSize, 0)}<br />
{_t("Indexed messages:")} {formatCountLong(this.state.eventCount)}<br /> {_t("Indexed messages:")} {formatCountLong(this.state.eventCount)}<br />
{_t("Number of rooms:")} {formatCountLong(this.state.roomCount)}<br /> {_t("Number of rooms:")} {formatCountLong(this.state.crawlingRoomsCount)} {_t("of ")}
{formatCountLong(this.state.roomCount)}<br />
{crawlerState}<br /> {crawlerState}<br />
<Field <Field
id={"crawlerSleepTimeMs"} id={"crawlerSleepTimeMs"}

View file

@ -2095,6 +2095,7 @@
"Space used:": "Space used:", "Space used:": "Space used:",
"Indexed messages:": "Indexed messages:", "Indexed messages:": "Indexed messages:",
"Number of rooms:": "Number of rooms:", "Number of rooms:": "Number of rooms:",
"of ": "of ",
"Message downloading sleep time(ms)": "Message downloading sleep time(ms)", "Message downloading sleep time(ms)": "Message downloading sleep time(ms)",
"Failed to set direct chat tag": "Failed to set direct chat tag", "Failed to set direct chat tag": "Failed to set direct chat tag",
"Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room", "Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room",

View file

@ -748,4 +748,31 @@ export default class EventIndex extends EventEmitter {
return client.getRoom(this.crawlerCheckpoints[0].roomId); return client.getRoom(this.crawlerCheckpoints[0].roomId);
} }
} }
crawlingRooms() {
const totalRooms = new Set();
const crawlingRooms = 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};
}
} }