Utilize timestamp from table instead of relying on getCurrentMillis.

This commit is contained in:
Alex Hart
2023-09-25 15:17:12 -03:00
committed by Cody Henthorne
parent fde0f3bba1
commit f5215d715a
2 changed files with 15 additions and 4 deletions

View File

@@ -806,6 +806,17 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
.run()
}
/**
* Gets the most recent timestamp from the [TIMESTAMP] column
*/
fun getLatestTimestamp(): Long {
val statement = """
SELECT $TIMESTAMP FROM $TABLE_NAME ORDER BY $TIMESTAMP DESC LIMIT 1
""".trimIndent()
return readableDatabase.query(statement).readToSingleLong(-1)
}
fun deleteNonAdHocCallEventsOnOrBefore(timestamp: Long) {
val messageIdsOnOrBeforeTimestamp = """
SELECT $MESSAGE_ID FROM $TABLE_NAME WHERE $TIMESTAMP <= $timestamp AND $MESSAGE_ID IS NOT NULL