mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 20:44:30 +08:00
5730d23da8
Summary: This diff modifies the SearchIndexer class to handle limiting the search index size. It does this by periodically re-evaluating the window of the n most recent items in a particular index where n is the max size of the index. It then unindexes the items which are marked as indexed but are no longer in the window and indexes the things that are in the window but aren't marked as indexed. Test Plan: Run locally with a reduced thread index size, verify that the index includes the most recent items and that it is the correct size. Also verify that the queries used properly use fast sqlite indices. Reviewers: evan, juan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3741
37 lines
662 B
JavaScript
37 lines
662 B
JavaScript
import {Event, ModelSearchIndexer} from 'nylas-exports'
|
|
|
|
|
|
const INDEX_VERSION = 1
|
|
|
|
class EventSearchIndexer extends ModelSearchIndexer {
|
|
|
|
get MaxIndexSize() {
|
|
return 5000;
|
|
}
|
|
|
|
get ConfigKey() {
|
|
return 'eventSearchIndexVersion';
|
|
}
|
|
|
|
get IndexVersion() {
|
|
return INDEX_VERSION;
|
|
}
|
|
|
|
get ModelClass() {
|
|
return Event;
|
|
}
|
|
|
|
getIndexDataForModel(event) {
|
|
const {title, description, location, participants} = event
|
|
return {
|
|
title,
|
|
location,
|
|
description,
|
|
participants: participants
|
|
.map((c) => `${c.name || ''} ${c.email || ''}`)
|
|
.join(' '),
|
|
}
|
|
}
|
|
}
|
|
|
|
export default new EventSearchIndexer()
|