mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
work towards composite keys
(builds but does not run because greendao generates wrong table creation code - we need to fix that)
This commit is contained in:
parent
b9df746ea6
commit
eb962c65f0
@ -157,7 +157,6 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addPebbleHealthActivityKindOverlay(Schema schema, Entity user, Entity device) {
|
||||
Entity activityOverlay = addEntity(schema, "PebbleHealthActivityOverlay");
|
||||
activityOverlay.addIdProperty();
|
||||
|
||||
Property userId = activityOverlay.addLongProperty("userId").getProperty();
|
||||
activityOverlay.addToOne(user, userId);
|
||||
@ -201,21 +200,14 @@ public class GBDaoGenerator {
|
||||
"This class represents a sample specific to the device. Values like activity kind or\n" +
|
||||
"intensity, are device specific. Normalized values can be retrieved through the\n" +
|
||||
"corresponding {@link SampleProvider}.");
|
||||
activitySample.addIdProperty();
|
||||
activitySample.addIntProperty("timestamp").notNull();
|
||||
activitySample.addIntProperty("timestamp").notNull().primaryKey();
|
||||
}
|
||||
|
||||
private static void addCommonActivitySampleProperties2(Entity activitySample, Entity user, Entity device) {
|
||||
Property userId = activitySample.addLongProperty("userId").getProperty();
|
||||
activitySample.addToOne(user, userId);
|
||||
Property deviceId = activitySample.addLongProperty("deviceId").getProperty();
|
||||
Property deviceId = activitySample.addLongProperty("deviceId").primaryKey().getProperty();
|
||||
activitySample.addToOne(device, deviceId);
|
||||
|
||||
Index indexUnique = new Index();
|
||||
indexUnique.addProperty(findProperty(activitySample, "timestamp"));
|
||||
indexUnique.addProperty(deviceId);
|
||||
indexUnique.makeUnique();
|
||||
activitySample.addIndex(indexUnique);
|
||||
}
|
||||
|
||||
private static Property findProperty(Entity entity, String propertyName) {
|
||||
|
@ -328,7 +328,6 @@ public class FetchActivityOperation extends AbstractMiBandOperation {
|
||||
}
|
||||
|
||||
samples[minutes] = new MiBandActivitySample(
|
||||
null,
|
||||
timestampInSeconds,
|
||||
intensity & 0xff,
|
||||
steps & 0xff,
|
||||
|
@ -83,7 +83,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
Long deviceId = DBHelper.getDevice(getDevice(), db.getDaoSession()).getId();
|
||||
for (int i = 0; i < samples; i++) {
|
||||
short sample = buf.getShort();
|
||||
misfitSamples[i] = new PebbleMisfitSample(null, timestamp + i * 60, userId, deviceId, sample & 0xffff);
|
||||
misfitSamples[i] = new PebbleMisfitSample(timestamp + i * 60, userId, deviceId, sample & 0xffff);
|
||||
misfitSamples[i].setProvider(sampleProvider);
|
||||
int steps = misfitSamples[i].getSteps();
|
||||
totalSteps += steps;
|
||||
|
@ -114,7 +114,7 @@ public class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
||||
Long userId = DBHelper.getUser(db.getDaoSession()).getId();
|
||||
Long deviceId = DBHelper.getDevice(getDevice(), db.getDaoSession()).getId();
|
||||
PebbleMorpheuzSampleProvider sampleProvider = new PebbleMorpheuzSampleProvider(getDevice(), db.getDaoSession());
|
||||
PebbleMorpheuzSample sample = new PebbleMorpheuzSample(null, recording_base_timestamp + index * 600, userId, deviceId, intensity);
|
||||
PebbleMorpheuzSample sample = new PebbleMorpheuzSample(recording_base_timestamp + index * 600, userId, deviceId, intensity);
|
||||
sample.setProvider(sampleProvider);
|
||||
sampleProvider.addGBActivitySample(sample);
|
||||
} catch (Exception e) {
|
||||
|
@ -72,7 +72,7 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth {
|
||||
|
||||
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
|
||||
for (OverlayRecord overlayRecord : overlayRecords) {
|
||||
overlayList.add(new PebbleHealthActivityOverlay(null, userId, deviceId, overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds - 1, overlayRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
overlayList.add(new PebbleHealthActivityOverlay(userId, deviceId, overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds - 1, overlayRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
}
|
||||
overlayDao.insertOrReplaceInTx(overlayList);
|
||||
} catch (Exception ex) {
|
||||
|
@ -71,7 +71,7 @@ class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth {
|
||||
|
||||
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
|
||||
for (SleepRecord sleepRecord : sleepRecords) {
|
||||
overlayList.add(new PebbleHealthActivityOverlay(null, userId, deviceId, sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd - 1, sleepRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
overlayList.add(new PebbleHealthActivityOverlay(userId, deviceId, sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd - 1, sleepRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
}
|
||||
overlayDao.insertOrReplaceInTx(overlayList);
|
||||
} catch (Exception ex) {
|
||||
|
@ -82,7 +82,6 @@ public class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth {
|
||||
for (int j = 0; j < stepsRecords.length; j++) {
|
||||
StepsRecord stepsRecord = stepsRecords[j];
|
||||
samples[j] = new PebbleHealthActivitySample(
|
||||
null,
|
||||
stepsRecord.timestamp,
|
||||
userId, deviceId,
|
||||
null, // raw data here
|
||||
|
Loading…
Reference in New Issue
Block a user