mirror of https://github.com/vector-im/riot-web
EventIndexPanel: Get more stats for our indexer, not just the size.
parent
695b8aff5b
commit
1b9b30d4ea
|
@ -35,6 +35,9 @@ export default class EventIndexPanel extends React.Component {
|
|||
eventIndexSize: 0,
|
||||
crawlingRooms: 0,
|
||||
totalCrawlingRooms: 0,
|
||||
eventCount: 0,
|
||||
roomCount: 0,
|
||||
currentRoom: null,
|
||||
eventIndexingEnabled:
|
||||
SettingsStore.getValueAt(SettingLevel.DEVICE, 'enableCrawling'),
|
||||
crawlerSleepTime:
|
||||
|
@ -44,22 +47,35 @@ export default class EventIndexPanel extends React.Component {
|
|||
|
||||
async componentWillMount(): void {
|
||||
let eventIndexSize = 0;
|
||||
let roomCount = 0;
|
||||
let eventCount = 0;
|
||||
let crawlingRooms = 0;
|
||||
let totalCrawlingRooms = 0;
|
||||
let currentRoom = null;
|
||||
|
||||
const eventIndex = EventIndexPeg.get();
|
||||
|
||||
if (eventIndex !== null) {
|
||||
eventIndexSize = await eventIndex.indexSize();
|
||||
const stats = await eventIndex.getStats();
|
||||
eventIndexSize = stats.size;
|
||||
roomCount = stats.roomCount;
|
||||
eventCount = stats.eventCount;
|
||||
|
||||
const crawledRooms = eventIndex.currentlyCrawledRooms();
|
||||
crawlingRooms = crawledRooms.crawlingRooms.size;
|
||||
totalCrawlingRooms = crawledRooms.totalRooms.size;
|
||||
|
||||
const room = eventIndex.currentRoom();
|
||||
if (room) currentRoom = room.name;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
eventIndexSize,
|
||||
crawlingRooms,
|
||||
totalCrawlingRooms,
|
||||
eventCount,
|
||||
roomCount,
|
||||
currentRoom,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -82,16 +98,15 @@ export default class EventIndexPanel extends React.Component {
|
|||
let crawlerState;
|
||||
|
||||
if (!this.state.eventIndexingEnabled) {
|
||||
crawlerState = <div>{_t("Message downloader is stopped.")}</div>;
|
||||
} else if (this.state.crawlingRooms === 0) {
|
||||
crawlerState = <div>{_t("Message downloader is currently idle.")}</div>;
|
||||
crawlerState = <div>{_t("Message search for encrypted rooms is disabled.")}</div>;
|
||||
} else if (this.state.currentRoom === null) {
|
||||
crawlerState = <div>{_t("Not currently downloading messages for any room.")}</div>;
|
||||
} else {
|
||||
crawlerState = (
|
||||
<div>{_t(
|
||||
"Currently downloading mesages in %(crawlingRooms)s of %(totalRooms)s rooms.",
|
||||
{ crawlingRooms: this.state.crawlingRooms,
|
||||
totalRooms: this.state.totalCrawlingRooms,
|
||||
})}
|
||||
"Downloading mesages for %(currentRoom)s.",
|
||||
{ currentRoom: this.state.currentRoom }
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -101,13 +116,14 @@ export default class EventIndexPanel extends React.Component {
|
|||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{_t("Encrypted search")}</span>
|
||||
{
|
||||
_t( "To enable search in encrypted rooms, Riot needs to run " +
|
||||
"a background process to download historical messages " +
|
||||
"from those rooms to your computer.",
|
||||
_t( "Riot is securely caching encrypted messages locally for them" +
|
||||
"to appear in search results:"
|
||||
)
|
||||
}
|
||||
<div className='mx_SettingsTab_subsectionText'>
|
||||
{_t("Message disk usage:")} {formatBytes(this.state.eventIndexSize, 0)}<br />
|
||||
{_t("Space used:")} {formatBytes(this.state.eventIndexSize, 0)}<br />
|
||||
{_t("Indexed messages:")} {this.state.eventCount}<br />
|
||||
{_t("Number of rooms:")} {this.state.roomCount}<br />
|
||||
{crawlerState}<br />
|
||||
</div>
|
||||
|
||||
|
|
|
@ -554,6 +554,16 @@
|
|||
"Failed to set display name": "Failed to set display name",
|
||||
"Disable Notifications": "Disable Notifications",
|
||||
"Enable Notifications": "Enable Notifications",
|
||||
"Message search for encrypted rooms is disabled.": "Message search for encrypted rooms is disabled.",
|
||||
"Not currently downloading messages for any room.": "Not currently downloading messages for any room.",
|
||||
"Downloading mesages for %(currentRoom)s.": "Downloading mesages for %(currentRoom)s.",
|
||||
"Encrypted search": "Encrypted search",
|
||||
"Riot is securely caching encrypted messages locally for themto appear in search results:": "Riot is securely caching encrypted messages locally for themto appear in search results:",
|
||||
"Space used:": "Space used:",
|
||||
"Indexed messages:": "Indexed messages:",
|
||||
"Number of rooms:": "Number of rooms:",
|
||||
"Download and index encrypted messages": "Download and index encrypted messages",
|
||||
"Message downloading sleep time(ms)": "Message downloading sleep time(ms)",
|
||||
"Connecting to integration manager...": "Connecting to integration manager...",
|
||||
"Cannot connect to integration manager": "Cannot connect to integration manager",
|
||||
"The integration manager is offline or it cannot reach your homeserver.": "The integration manager is offline or it cannot reach your homeserver.",
|
||||
|
@ -732,14 +742,6 @@
|
|||
"Start automatically after system login": "Start automatically after system login",
|
||||
"Always show the window menu bar": "Always show the window menu bar",
|
||||
"Show tray icon and minimize window to it on close": "Show tray icon and minimize window to it on close",
|
||||
"Message downloader is stopped.": "Message downloader is stopped.",
|
||||
"Message downloader is currently idle.": "Message downloader is currently idle.",
|
||||
"Currently downloading mesages in %(crawlingRooms)s of %(totalRooms)s rooms.": "Currently downloading mesages in %(crawlingRooms)s of %(totalRooms)s rooms.",
|
||||
"Encrypted search": "Encrypted search",
|
||||
"To enable search in encrypted rooms, Riot needs to run a background process to download historical messages from those rooms to your computer.": "To enable search in encrypted rooms, Riot needs to run a background process to download historical messages from those rooms to your computer.",
|
||||
"Message disk usage:": "Message disk usage:",
|
||||
"Download and index encrypted messages": "Download and index encrypted messages",
|
||||
"Message downloading sleep time(ms)": "Message downloading sleep time(ms)",
|
||||
"Preferences": "Preferences",
|
||||
"Composer": "Composer",
|
||||
"Timeline": "Timeline",
|
||||
|
|
|
@ -67,6 +67,12 @@ export interface HistoricEvent {
|
|||
profile: MatrixProfile;
|
||||
}
|
||||
|
||||
export interface IndexStats {
|
||||
size: number;
|
||||
event_count: number;
|
||||
room_count: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for classes that provide platform-specific event indexing.
|
||||
*
|
||||
|
@ -118,9 +124,12 @@ export default class BaseEventIndexManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the disk usage of the index
|
||||
* Get statistical information of the index.
|
||||
*
|
||||
* @return {Promise<IndexStats>} A promise that will resolve to the index
|
||||
* statistics.
|
||||
*/
|
||||
async indexSize(): Promise<number> {
|
||||
async getStats(): Promise<IndexStats> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
|
|
|
@ -425,9 +425,9 @@ export default class EventIndex {
|
|||
return indexManager.searchEventIndex(searchArgs);
|
||||
}
|
||||
|
||||
async indexSize() {
|
||||
async getStats() {
|
||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||
return indexManager.indexSize();
|
||||
return indexManager.getStats();
|
||||
}
|
||||
|
||||
currentlyCrawledRooms() {
|
||||
|
@ -456,4 +456,27 @@ export default class EventIndex {
|
|||
|
||||
return {crawlingRooms, totalRooms};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the room that we are currently crawling.
|
||||
*
|
||||
* @returns A MatrixRoom that is being currently crawled, null if no room is
|
||||
* currently being crawled.
|
||||
*/
|
||||
currentRoom() {
|
||||
if (this._currentCheckpoint === null && this.crawlerCheckpoints.length === 0) {
|
||||
console.log("EventIndex: No current nor any checkpoint");
|
||||
return null;
|
||||
}
|
||||
|
||||
const client = MatrixClientPeg.get();
|
||||
|
||||
if (this._currentCheckpoint !== null) {
|
||||
console.log("EventIndex: Current checkpoint available");
|
||||
return client.getRoom(this._currentCheckpoint.roomId);
|
||||
} else {
|
||||
console.log("EventIndex: No current but have checkpoint available");
|
||||
return client.getRoom(this.crawlerCheckpoints[0].roomId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue