1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-29 11:15:51 +00:00

Optimized FTS conditions

This commit is contained in:
M66B 2021-10-11 15:20:31 +02:00
parent 33b25689ba
commit 9358a21e70

View file

@ -283,6 +283,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
" ids=" + state.ids.size()); " ids=" + state.ids.size());
} }
List<Long> excluded = Helper.fromLongArray(exclude);
try { try {
db.beginTransaction(); db.beginTransaction();
@ -313,27 +315,30 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
continue; continue;
} }
if (excluded.contains(message.folder))
continue;
boolean matched = false; boolean matched = false;
if (criteria.in_senders) { if (!matched && criteria.in_senders) {
if (contains(message.from, query)) if (contains(message.from, query))
matched = true; matched = true;
} }
if (criteria.in_recipients) { if (!matched && criteria.in_recipients) {
if (contains(message.to, query) || if (contains(message.to, query) ||
contains(message.cc, query) || contains(message.cc, query) ||
contains(message.bcc, query)) contains(message.bcc, query))
matched = true; matched = true;
} }
if (criteria.in_subject) { if (!matched && criteria.in_subject) {
if (message.subject != null && if (message.subject != null &&
message.subject.toLowerCase().contains(query)) message.subject.toLowerCase().contains(query))
matched = true; matched = true;
} }
if (criteria.in_keywords) { if (!matched && criteria.in_keywords) {
if (message.keywords != null) if (message.keywords != null)
for (String keyword : message.keywords) for (String keyword : message.keywords)
if (keyword.toLowerCase().contains(query)) { if (keyword.toLowerCase().contains(query)) {
@ -342,7 +347,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
} }
} }
if (criteria.in_notes) { if (!matched && criteria.in_notes) {
if (message.notes != null && if (message.notes != null &&
message.notes.toLowerCase().contains(query)) message.notes.toLowerCase().contains(query))
matched = true; matched = true;
@ -364,20 +369,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
Log.e(ex); Log.e(ex);
} }
if (!criteria.in_trash || !criteria.in_junk) {
EntityFolder folder = db.folder().getFolder(message.folder);
if (folder == null)
continue;
if (!criteria.in_trash) {
if (EntityFolder.TRASH.equals(folder.type))
continue;
}
if (!criteria.in_junk) {
if (EntityFolder.JUNK.equals(folder.type))
continue;
}
}
if (!matched) if (!matched)
continue; continue;