1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 09:17:29 +01:00

db refactoring: add proposed schema for pebble health overlays

This commit is contained in:
Andreas Shimokawa 2016-08-08 09:01:36 +02:00
parent af58b4600d
commit b708ad942e

View File

@ -46,6 +46,7 @@ public class GBDaoGenerator {
addMiBandActivitySample(schema, user, device);
addPebbleHealthActivitySample(schema, user, device);
addPebbleHealthActivityKindOverlay(schema, user, device);
addPebbleMisfitActivitySample(schema, user, device);
addPebbleMorpheuzActivitySample(schema, user, device);
@ -152,6 +153,28 @@ public class GBDaoGenerator {
return activitySample;
}
private static Entity addPebbleHealthActivityKindOverlay(Schema schema, Entity user, Entity device) {
Entity activityOverlay = addEntity(schema, "PebbleHealthActivityOverlay");
activityOverlay.addIdProperty();
Property timestampFrom = activityOverlay.addIntProperty("timestampFrom").notNull().getProperty();
Property timestampTo = activityOverlay.addIntProperty("timestampTo").notNull().getProperty();
activityOverlay.addIntProperty("rawKind").notNull();
Property userId = activityOverlay.addLongProperty("userId").getProperty();
activityOverlay.addToOne(user, userId);
Property deviceId = activityOverlay.addLongProperty("deviceId").getProperty();
activityOverlay.addToOne(device, deviceId);
Index indexUnique = new Index();
indexUnique.addProperty(deviceId);
indexUnique.addProperty(timestampFrom);
indexUnique.addProperty(timestampTo);
indexUnique.makeUnique();
activityOverlay.addIndex(indexUnique);
return activityOverlay;
}
private static Entity addPebbleMisfitActivitySample(Schema schema, Entity user, Entity device) {
Entity activitySample = addEntity(schema, "PebbleMisfitSample");
addCommonActivitySampleProperties("AbstractPebbleMisfitActivitySample", activitySample, user, device);