[client-app] Don't compute thread search index size on startup

Summary:
We did this to see if we should clear the index, which no longer makes
sense because the index never exceeds our threshold. Additionally, none
of the other search indexes do this. This was causing us to spend a ton
of time scanning the ThreadSearch table at startup.

Test Plan: Run locally, make sure things are fine

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4007
This commit is contained in:
Mark Hahnenberg 2017-02-21 16:23:07 -08:00
parent 84a3b20839
commit 7b55691cee
2 changed files with 1 additions and 15 deletions

View file

@ -64,15 +64,7 @@ class ThreadSearchIndexStore {
.then(() => this.buildIndex(this.accountIds))
}
return DatabaseStore.searchIndexSize(Thread)
.then((size) => {
console.log(`Thread Search: Current index size is ${(size || 0)} threads`)
if (this._isInvalidSize(size)) {
return this.clearIndex().thenReturn(this.accountIds)
}
return this.getUnindexedAccounts()
})
.then((accountIds) => this.buildIndex(accountIds))
return this.getUnindexedAccounts().then((accountIds) => this.buildIndex(accountIds));
}
/**

View file

@ -729,12 +729,6 @@ class DatabaseStore extends NylasStore {
return this._query(sql);
}
searchIndexSize(klass) {
const searchTableName = `${klass.name}Search`;
const sql = `SELECT COUNT(content_id) as count FROM \`${searchTableName}\``;
return this._query(sql).then((result) => result[0].count);
}
isIndexEmptyForAccount(accountId, modelKlass) {
const modelTable = modelKlass.name
const sql = (