Fix the issue that no data is returned when there is no full charge data

in the database.

Test: make RunSettingsRoboTests + manual
Bug: 260938983
Bug: 253553141
Change-Id: Ie12f239ce83a6ac2cd95c1663cd82e2974a7eaf3
This commit is contained in:
Kuan Wang
2022-12-01 12:04:12 +08:00
parent 8b49b96569
commit 362def5275
2 changed files with 22 additions and 6 deletions

View File

@@ -43,8 +43,8 @@ public interface BatteryStateDao {
/** Gets the {@link Cursor} of all recorded data since last full charge within 7 days. */
@Query("SELECT * FROM BatteryState WHERE timestamp >= :timestampSixDaysAgo AND timestamp >= "
+ "(SELECT MAX(timestamp) FROM BatteryState WHERE isFullChargeCycleStart = 1)"
+ " ORDER BY timestamp ASC")
+ "(SELECT IFNULL((SELECT MAX(timestamp) FROM BatteryState "
+ "WHERE isFullChargeCycleStart = 1), 0)) ORDER BY timestamp ASC")
Cursor getCursorSinceLastFullCharge(long timestampSixDaysAgo);
/** Get the count of distinct timestamp after a specific timestamp. */