Sort frequently contacted on lookup URI

pull/153/head
M66B 6 years ago
parent cc1264698c
commit 2ac17dda85

File diff suppressed because it is too large Load Diff

@ -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();
}

@ -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")

@ -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"})

Loading…
Cancel
Save