Sort frequently contacted on lookup URI

This commit is contained in:
M66B 2019-03-17 09:49:50 +00:00
parent cc1264698c
commit 2ac17dda85
4 changed files with 1644 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 58,
version = 59,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -648,6 +648,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("CREATE INDEX `index_contact_state` ON `contact` (`state`)");
}
})
.addMigrations(new Migration(58, 59) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("CREATE INDEX `index_contact_avatar` ON `contact` (`avatar`)");
}
})
.build();
}

View File

@ -45,6 +45,7 @@ public interface DaoContact {
" WHERE state <> " + EntityContact.STATE_IGNORE +
" ORDER BY" +
" CASE WHEN state = " + EntityContact.STATE_FAVORITE + " THEN 0 ELSE 1 END" +
", CASE WHEN avatar IS NULL THEN 1 ELSE 0 END" +
", times_contacted DESC" +
", last_contacted DESC" +
" LIMIT :count")

View File

@ -45,6 +45,7 @@ import static androidx.room.ForeignKey.CASCADE;
@Index(value = {"account", "type", "email"}, unique = true),
@Index(value = {"email"}),
@Index(value = {"name"}),
@Index(value = {"avatar"}),
@Index(value = {"times_contacted"}),
@Index(value = {"last_contacted"}),
@Index(value = {"state"})