Remove old insight db tables
This commit is contained in:
parent
835a87cfe4
commit
afb16210ae
3 changed files with 0 additions and 129 deletions
|
@ -23,7 +23,6 @@ import javax.inject.Inject;
|
|||
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
|
@ -67,15 +66,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
|
||||
try {
|
||||
aapsLogger.info(LTag.DATABASE, "onCreate");
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, OmnipodHistoryRecord.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, OHQueueItem.class);
|
||||
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_BOLUS_IDS + "\")");
|
||||
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_PUMP_IDS + "\")");
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Can't create database", e);
|
||||
throw new RuntimeException(e);
|
||||
|
@ -91,17 +83,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
if (oldVersion < 7) {
|
||||
aapsLogger.info(LTag.DATABASE, "onUpgrade");
|
||||
onCreate(database, connectionSource);
|
||||
} else if (oldVersion < 10) {
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightHistoryOffset.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightBolusID.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, InsightPumpID.class);
|
||||
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_BOLUS_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_BOLUS_IDS + "\")");
|
||||
database.execSQL("INSERT INTO sqlite_sequence (name, seq) SELECT \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_PUMP_IDS + "\", " + System.currentTimeMillis() + " " +
|
||||
"WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_PUMP_IDS + "\")");
|
||||
} else if (oldVersion < 11) {
|
||||
database.execSQL("UPDATE sqlite_sequence SET seq = " + System.currentTimeMillis() + " WHERE name = \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_BOLUS_IDS + "\"");
|
||||
database.execSQL("UPDATE sqlite_sequence SET seq = " + System.currentTimeMillis() + " WHERE name = \"" + DatabaseHelperInterface.Companion.DATABASE_INSIGHT_PUMP_IDS + "\"");
|
||||
}
|
||||
TableUtils.createTableIfNotExists(connectionSource, OHQueueItem.class);
|
||||
} catch (SQLException e) {
|
||||
|
@ -152,18 +133,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
|
||||
// ------------------ getDao -------------------------------------------
|
||||
|
||||
private Dao<InsightPumpID, Long> getDaoInsightPumpID() throws SQLException {
|
||||
return getDao(InsightPumpID.class);
|
||||
}
|
||||
|
||||
private Dao<InsightBolusID, Long> getDaoInsightBolusID() throws SQLException {
|
||||
return getDao(InsightBolusID.class);
|
||||
}
|
||||
|
||||
private Dao<InsightHistoryOffset, String> getDaoInsightHistoryOffset() throws SQLException {
|
||||
return getDao(InsightHistoryOffset.class);
|
||||
}
|
||||
|
||||
private Dao<OmnipodHistoryRecord, Long> getDaoPodHistory() throws SQLException {
|
||||
return getDao(OmnipodHistoryRecord.class);
|
||||
}
|
||||
|
@ -182,68 +151,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------- Insight history handling ---------------
|
||||
|
||||
public void createOrUpdate(InsightHistoryOffset offset) {
|
||||
try {
|
||||
getDaoInsightHistoryOffset().createOrUpdate(offset);
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public InsightHistoryOffset getInsightHistoryOffset(String pumpSerial) {
|
||||
try {
|
||||
return getDaoInsightHistoryOffset().queryForId(pumpSerial);
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void createOrUpdate(InsightBolusID bolusID) {
|
||||
try {
|
||||
getDaoInsightBolusID().createOrUpdate(bolusID);
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public InsightBolusID getInsightBolusID(String pumpSerial, int bolusID, long timestamp) {
|
||||
try {
|
||||
return getDaoInsightBolusID().queryBuilder()
|
||||
.where().eq("pumpSerial", pumpSerial)
|
||||
.and().eq("bolusID", bolusID)
|
||||
.and().between("timestamp", timestamp - 259200000, timestamp + 259200000)
|
||||
.queryForFirst();
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void createOrUpdate(InsightPumpID pumpID) {
|
||||
try {
|
||||
getDaoInsightPumpID().createOrUpdate(pumpID);
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public InsightPumpID getPumpStoppedEvent(String pumpSerial, long before) {
|
||||
try {
|
||||
return getDaoInsightPumpID().queryBuilder()
|
||||
.orderBy("timestamp", false)
|
||||
.where().eq("pumpSerial", pumpSerial)
|
||||
.and().in("eventType", "PumpStopped", "PumpPaused")
|
||||
.and().lt("timestamp", before)
|
||||
.queryForFirst();
|
||||
} catch (SQLException e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------- Food handling ---------------
|
||||
|
||||
// ---------------- PodHistory handling ---------------
|
||||
|
|
|
@ -49,18 +49,6 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface {
|
|||
return MainApp.Companion.getDbHelper().findOmnipodHistoryRecordByPumpId(pumpId);
|
||||
}
|
||||
|
||||
@Override public void createOrUpdate(@NonNull InsightBolusID record) {
|
||||
MainApp.Companion.getDbHelper().createOrUpdate(record);
|
||||
}
|
||||
|
||||
@Override public void createOrUpdate(@NonNull InsightPumpID record) {
|
||||
MainApp.Companion.getDbHelper().createOrUpdate(record);
|
||||
}
|
||||
|
||||
@Override public void createOrUpdate(@NonNull InsightHistoryOffset record) {
|
||||
MainApp.Companion.getDbHelper().createOrUpdate(record);
|
||||
}
|
||||
|
||||
@Override public void delete(@NonNull ExtendedBolus extendedBolus) {
|
||||
// MainApp.Companion.getDbHelper().delete(extendedBolus);
|
||||
}
|
||||
|
@ -70,18 +58,6 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable @Override public InsightBolusID getInsightBolusID(@NonNull String pumpSerial, int bolusID, long timestamp) {
|
||||
return MainApp.Companion.getDbHelper().getInsightBolusID(pumpSerial, bolusID, timestamp);
|
||||
}
|
||||
|
||||
@Nullable @Override public InsightHistoryOffset getInsightHistoryOffset(@NonNull String pumpSerial) {
|
||||
return MainApp.Companion.getDbHelper().getInsightHistoryOffset(pumpSerial);
|
||||
}
|
||||
|
||||
@Nullable @Override public InsightPumpID getPumpStoppedEvent(@NonNull String pumpSerial, long before) {
|
||||
return MainApp.Companion.getDbHelper().getPumpStoppedEvent(pumpSerial, before);
|
||||
}
|
||||
|
||||
@Override public void resetDatabases() {
|
||||
MainApp.Companion.getDbHelper().resetDatabases();
|
||||
}
|
||||
|
|
|
@ -7,9 +7,6 @@ interface DatabaseHelperInterface {
|
|||
fun resetDatabases()
|
||||
|
||||
fun createOrUpdate(record: OmnipodHistoryRecord)
|
||||
fun createOrUpdate(record: InsightBolusID)
|
||||
fun createOrUpdate(record: InsightPumpID)
|
||||
fun createOrUpdate(record: InsightHistoryOffset)
|
||||
fun createOrUpdate(record: OHQueueItem)
|
||||
fun delete(extendedBolus: ExtendedBolus)
|
||||
fun createOrUpdate(tempBasal: TemporaryBasal): Boolean
|
||||
|
@ -24,18 +21,9 @@ interface DatabaseHelperInterface {
|
|||
fun getAllOHQueueItems(maxEntries: Long): List<OHQueueItem>
|
||||
|
||||
// old DB model
|
||||
fun getInsightBolusID(pumpSerial: String, bolusID: Int, timestamp: Long): InsightBolusID?
|
||||
fun getInsightHistoryOffset(pumpSerial: String): InsightHistoryOffset?
|
||||
fun getPumpStoppedEvent(pumpSerial: String, before: Long): InsightPumpID?
|
||||
|
||||
fun getOHQueueSize(): Long
|
||||
fun clearOpenHumansQueue()
|
||||
fun removeAllOHQueueItemsWithIdSmallerThan(id: Long)
|
||||
|
||||
companion object {
|
||||
|
||||
const val DATABASE_INSIGHT_HISTORY_OFFSETS = "InsightHistoryOffsets"
|
||||
const val DATABASE_INSIGHT_BOLUS_IDS = "InsightBolusIDs"
|
||||
const val DATABASE_INSIGHT_PUMP_IDS = "InsightPumpIDs"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue