Geary.ImapDb.SearchQuery: Rename to Geary.FtsSearchQuery

There's nothing IMAP-specific about the class, so move it to common
and rename to reflect what it is actually used for.
This commit is contained in:
Michael Gratton 2020-11-05 00:21:39 +11:00 committed by Michael James Gratton
parent 2ab7b2c39e
commit 20a4fd3ed2
8 changed files with 27 additions and 24 deletions

View file

@ -211,6 +211,7 @@ src/engine/app/email-store/app-mark-operation.vala
src/engine/common/common-contact-harvester.vala
src/engine/common/common-contact-store-impl.vala
src/engine/common/common-message-data.vala
src/engine/common/common-fts-search-query.vala
src/engine/db/db.vala
src/engine/db/db-connection.vala
src/engine/db/db-context.vala
@ -269,7 +270,6 @@ src/engine/imap-db/imap-db-email-identifier.vala
src/engine/imap-db/imap-db-folder.vala
src/engine/imap-db/imap-db-gc.vala
src/engine/imap-db/imap-db-message-row.vala
src/engine/imap-db/imap-db-search-query.vala
src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
src/engine/imap-engine/gmail/imap-engine-gmail-all-mail-folder.vala
src/engine/imap-engine/gmail/imap-engine-gmail-drafts-folder.vala

View file

@ -7,9 +7,9 @@
*/
/**
* Internal implementation of {@link Geary.SearchQuery}.
* A search query implementation that provides full-text search.
*/
private class Geary.ImapDB.SearchQuery : Geary.SearchQuery {
internal class Geary.FtsSearchQuery : Geary.SearchQuery {
private const string EMAIL_TEXT_STEMMED_TERMS = "geary-stemmed-terms";
@ -22,9 +22,9 @@ private class Geary.ImapDB.SearchQuery : Geary.SearchQuery {
private unowned SnowBall.Stemmer stemmer;
public SearchQuery(Gee.List<Term> expression,
string raw,
SnowBall.Stemmer stemmer) {
public FtsSearchQuery(Gee.List<Term> expression,
string raw,
SnowBall.Stemmer stemmer) {
base(expression, raw);
this.stemmer = stemmer;

View file

@ -585,7 +585,7 @@ private class Geary.ImapDB.Account : BaseObject {
debug("Search query: %s", q.to_string());
check_open();
ImapDB.SearchQuery query = check_search_query(q);
FtsSearchQuery query = check_search_query(q);
// Do this outside of transaction to catch invalid search ids up-front
string? search_ids_sql = get_search_ids_sql(search_ids);
@ -696,7 +696,7 @@ private class Geary.ImapDB.Account : BaseObject {
public async Gee.Set<string>? get_search_matches_async(Geary.SearchQuery q,
Gee.Collection<ImapDB.EmailIdentifier> ids, Cancellable? cancellable = null) throws Error {
check_open();
ImapDB.SearchQuery query = check_search_query(q);
FtsSearchQuery query = check_search_query(q);
Gee.Set<string>? search_matches = null;
yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
@ -1223,7 +1223,7 @@ private class Geary.ImapDB.Account : BaseObject {
// not per key-value
public Gee.Map<ImapDB.EmailIdentifier, Gee.Set<string>> do_get_search_matches(
Db.Connection cx,
ImapDB.SearchQuery query,
FtsSearchQuery query,
Gee.Map<int64?, ImapDB.EmailIdentifier> id_map,
GLib.Cancellable? cancellable
) throws GLib.Error {
@ -1327,8 +1327,8 @@ private class Geary.ImapDB.Account : BaseObject {
}
}
private ImapDB.SearchQuery check_search_query(Geary.SearchQuery q) throws Error {
ImapDB.SearchQuery? query = q as ImapDB.SearchQuery;
private FtsSearchQuery check_search_query(Geary.SearchQuery q) throws Error {
var query = q as FtsSearchQuery;
if (query == null) {
throw new EngineError.BAD_PARAMETERS("Geary.SearchQuery not associated with %s", name);
}

View file

@ -580,7 +580,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
string text,
GLib.Cancellable? cancellable
) throws GLib.Error {
return new ImapDB.SearchQuery(expression, text, this.stemmer);
return new FtsSearchQuery(expression, text, this.stemmer);
}
public override async Gee.MultiMap<Geary.Email, Geary.FolderPath?>? local_search_message_id_async(

View file

@ -67,6 +67,7 @@ engine_vala_sources = files(
'common/common-contact-harvester.vala',
'common/common-contact-store-impl.vala',
'common/common-fts-search-query.vala',
'common/common-message-data.vala',
'db/db.vala',
@ -179,7 +180,6 @@ engine_vala_sources = files(
'imap-db/imap-db-fts5-matches.c',
'imap-db/imap-db-gc.vala',
'imap-db/imap-db-message-row.vala',
'imap-db/imap-db-search-query.vala',
'imap-db/imap-db-sqlite.c',
'imap-engine/imap-engine.vala',

View file

@ -5,17 +5,17 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
public class Geary.ImapDB.SearchQueryTest : TestCase {
public class Geary.FtsSearchQueryTest : TestCase {
private GLib.File? tmp_dir = null;
private Geary.AccountInformation? config = null;
private Account? account = null;
private ImapDB.Account? account = null;
private SnowBall.Stemmer? stemmer = null;
public SearchQueryTest() {
base("Geary.ImapDB.SearchQueryTest");
public FtsSearchQueryTest() {
base("Geary.FtsSearchQueryTest");
add_test("email_text_terms", email_text_terms);
add_test("email_text_terms_stemmed", email_text_terms_stemmed);
add_test("email_text_terms_specific", email_text_terms_specific);
@ -25,7 +25,7 @@ public class Geary.ImapDB.SearchQueryTest : TestCase {
public override void set_up() throws GLib.Error {
this.tmp_dir = GLib.File.new_for_path(
GLib.DirUtils.make_tmp("geary-imap-db-search-query-test-XXXXXX")
GLib.DirUtils.make_tmp("geary-common-fts-search-query-test-XXXXXX")
);
this.config = new Geary.AccountInformation(
@ -35,7 +35,7 @@ public class Geary.ImapDB.SearchQueryTest : TestCase {
new Geary.RFC822.MailboxAddress(null, "test@example.com")
);
this.account = new Account(
this.account = new ImapDB.Account(
config,
this.tmp_dir,
GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql")
@ -212,16 +212,17 @@ public class Geary.ImapDB.SearchQueryTest : TestCase {
search_with_both.exec(null);
}
private SearchQuery new_search_query(Geary.SearchQuery.Term[] ops, string raw)
private FtsSearchQuery new_search_query(Geary.SearchQuery.Term[] ops,
string raw)
throws GLib.Error {
return new SearchQuery(
return new FtsSearchQuery(
new Gee.ArrayList<Geary.SearchQuery.Term>.wrap(ops),
raw,
this.stemmer
);
}
private void assert_queries(SearchQuery query) throws GLib.Error {
private void assert_queries(FtsSearchQuery query) throws GLib.Error {
var search = query.get_search_query(
this.account.db.get_primary_connection(),
null,

View file

@ -36,6 +36,7 @@ test_engine_sources = [
'engine/app/app-conversation-set-test.vala',
'engine/common/common-contact-store-impl-test.vala',
'engine/common/common-contact-harvester-test.vala',
'engine/common/common-fts-search-query-test.vala',
'engine/db/db-database-test.vala',
'engine/db/db-versioned-database-test.vala',
'engine/imap/command/imap-create-command-test.vala',
@ -53,7 +54,6 @@ test_engine_sources = [
'engine/imap-db/imap-db-database-test.vala',
'engine/imap-db/imap-db-email-identifier-test.vala',
'engine/imap-db/imap-db-folder-test.vala',
'engine/imap-db/imap-db-search-query-test.vala',
'engine/imap-engine/account-processor-test.vala',
'engine/imap-engine/imap-engine-generic-account-test.vala',
'engine/mime/mime-content-type-test.vala',

View file

@ -72,7 +72,9 @@ int main(string[] args) {
engine.add_suite(new Geary.ImapDB.DatabaseTest().suite);
engine.add_suite(new Geary.ImapDB.EmailIdentifierTest().suite);
engine.add_suite(new Geary.ImapDB.FolderTest().suite);
engine.add_suite(new Geary.ImapDB.SearchQueryTest().suite);
// Depends on ImapDB working
engine.add_suite(new Geary.FtsSearchQueryTest().suite);
engine.add_suite(new Geary.ImapEngine.AccountProcessorTest().suite);
engine.add_suite(new Geary.ImapEngine.GenericAccountTest().suite);