From 3fb558c53663773bb0e0c8f1f11d15c00f703d08 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 18 Aug 2016 22:06:26 +0200 Subject: [PATCH] db refactoring: add raw data column in health overlay table and make rawType part of the composite key --- .../freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java | 4 ++-- .../devices/pebble/DatalogSessionHealthOverlayData.java | 2 +- .../service/devices/pebble/DatalogSessionHealthSleep.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java index 24e2f53ba..bc1eeefde 100644 --- a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java +++ b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java @@ -17,7 +17,6 @@ package nodomain.freeyourgadget.gadgetbridge.daogen; import de.greenrobot.daogenerator.DaoGenerator; import de.greenrobot.daogenerator.Entity; -import de.greenrobot.daogenerator.Index; import de.greenrobot.daogenerator.Property; import de.greenrobot.daogenerator.Schema; @@ -159,12 +158,13 @@ public class GBDaoGenerator { activityOverlay.addIntProperty("timestampFrom").notNull().primaryKey(); activityOverlay.addIntProperty("timestampTo").notNull().primaryKey(); + activityOverlay.addIntProperty("rawKind").notNull().primaryKey(); Property deviceId = activityOverlay.addLongProperty("deviceId").primaryKey().getProperty(); activityOverlay.addToOne(device, deviceId); Property userId = activityOverlay.addLongProperty("userId").getProperty(); activityOverlay.addToOne(user, userId); - activityOverlay.addIntProperty("rawKind").notNull(); + activityOverlay.addByteArrayProperty("rawPebbleHealthData"); return activityOverlay; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java index 0c696335c..db7c21fe5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java @@ -72,7 +72,7 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth { List overlayList = new ArrayList<>(); for (OverlayRecord overlayRecord : overlayRecords) { - overlayList.add(new PebbleHealthActivityOverlay(overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds, deviceId, userId, overlayRecord.type)); //TODO: consider if "-1" is what we really want + overlayList.add(new PebbleHealthActivityOverlay(overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds, overlayRecord.type, deviceId, userId, null)); } overlayDao.insertOrReplaceInTx(overlayList); } catch (Exception ex) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java index e1ff8d9fa..5115be5b5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java @@ -71,7 +71,7 @@ class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth { List overlayList = new ArrayList<>(); for (SleepRecord sleepRecord : sleepRecords) { - overlayList.add(new PebbleHealthActivityOverlay(sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd, deviceId, userId, sleepRecord.type)); //TODO: consider if "-1" is what we really want + overlayList.add(new PebbleHealthActivityOverlay(sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd, sleepRecord.type, deviceId, userId, null)); } overlayDao.insertOrReplaceInTx(overlayList); } catch (Exception ex) {