mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01:00
db refactoring: depend on latest -fyg patched greendao, change column order again (primary keys first), remove index from pebble health overlay also
This commit is contained in:
parent
eb962c65f0
commit
69933c5e92
@ -7,7 +7,8 @@ archivesBaseName = 'gadgetbridge-daogenerator'
|
||||
|
||||
dependencies {
|
||||
// compile 'org.greenrobot:greendao-generator:2.2.0'
|
||||
compile 'com.github.freeyourgadget:greendao:c3830951e5dd3d1e63d7bac600d5f773b81df363'
|
||||
// compile project(":DaoGenerator")
|
||||
compile 'com.github.freeyourgadget:greendao:1998d7cd2d21f662c6044f6ccf3b3a251bbad341'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -34,7 +34,7 @@ public class GBDaoGenerator {
|
||||
private static final String VALID_BY_DATE = MODEL_PACKAGE + ".ValidByDate";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Schema schema = new Schema(12, MAIN_PACKAGE + ".entities");
|
||||
Schema schema = new Schema(13, MAIN_PACKAGE + ".entities");
|
||||
|
||||
addActivityDescription(schema);
|
||||
|
||||
@ -136,7 +136,6 @@ public class GBDaoGenerator {
|
||||
activitySample.addIntProperty("rawIntensity").notNull();
|
||||
activitySample.addIntProperty("steps").notNull();
|
||||
activitySample.addIntProperty("rawKind").notNull();
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
addHeartRateProperties(activitySample);
|
||||
return activitySample;
|
||||
}
|
||||
@ -148,7 +147,6 @@ public class GBDaoGenerator {
|
||||
private static Entity addPebbleHealthActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "PebbleHealthActivitySample");
|
||||
addCommonActivitySampleProperties("AbstractPebbleHealthActivitySample", activitySample, user, device);
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
activitySample.addByteArrayProperty("rawPebbleHealthData");
|
||||
activitySample.addIntProperty("rawIntensity").notNull();
|
||||
activitySample.addIntProperty("steps").notNull();
|
||||
@ -158,29 +156,21 @@ public class GBDaoGenerator {
|
||||
private static Entity addPebbleHealthActivityKindOverlay(Schema schema, Entity user, Entity device) {
|
||||
Entity activityOverlay = addEntity(schema, "PebbleHealthActivityOverlay");
|
||||
|
||||
Property userId = activityOverlay.addLongProperty("userId").getProperty();
|
||||
activityOverlay.addToOne(user, userId);
|
||||
Property deviceId = activityOverlay.addLongProperty("deviceId").getProperty();
|
||||
activityOverlay.addIntProperty("timestampFrom").notNull().primaryKey();
|
||||
activityOverlay.addIntProperty("timestampTo").notNull().primaryKey();
|
||||
Property deviceId = activityOverlay.addLongProperty("deviceId").primaryKey().getProperty();
|
||||
activityOverlay.addToOne(device, deviceId);
|
||||
|
||||
Property timestampFrom = activityOverlay.addIntProperty("timestampFrom").notNull().getProperty();
|
||||
Property timestampTo = activityOverlay.addIntProperty("timestampTo").notNull().getProperty();
|
||||
Property userId = activityOverlay.addLongProperty("userId").getProperty();
|
||||
activityOverlay.addToOne(user, userId);
|
||||
activityOverlay.addIntProperty("rawKind").notNull();
|
||||
|
||||
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);
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
activitySample.addIntProperty("rawPebbleMisfitSample").notNull();
|
||||
return activitySample;
|
||||
}
|
||||
@ -188,7 +178,6 @@ public class GBDaoGenerator {
|
||||
private static Entity addPebbleMorpheuzActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "PebbleMorpheuzSample");
|
||||
addCommonActivitySampleProperties("AbstractPebbleMorpheuzActivitySample", activitySample, user, device);
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
activitySample.addIntProperty("rawIntensity").notNull();
|
||||
return activitySample;
|
||||
}
|
||||
@ -201,13 +190,10 @@ public class GBDaoGenerator {
|
||||
"intensity, are device specific. Normalized values can be retrieved through the\n" +
|
||||
"corresponding {@link SampleProvider}.");
|
||||
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").primaryKey().getProperty();
|
||||
activitySample.addToOne(device, deviceId);
|
||||
Property userId = activitySample.addLongProperty("userId").getProperty();
|
||||
activitySample.addToOne(user, userId);
|
||||
}
|
||||
|
||||
private static Property findProperty(Entity entity, String propertyName) {
|
||||
|
@ -59,8 +59,10 @@ dependencies {
|
||||
compile 'com.github.pfichtner:durationformatter:0.1.1'
|
||||
compile 'de.cketti.library.changelog:ckchangelog:1.2.2'
|
||||
compile 'net.e175.klaus:solarpositioning:0.0.9'
|
||||
compile 'com.github.freeyourgadget:greendao:c3830951e5dd3d1e63d7bac600d5f773b81df363'
|
||||
compile 'com.github.freeyourgadget:greendao:1998d7cd2d21f662c6044f6ccf3b3a251bbad341'
|
||||
compile 'com.github.woxthebox:draglistview:1.2.6'
|
||||
|
||||
// compile project(":DaoCore")
|
||||
}
|
||||
|
||||
preBuild.dependsOn(":GBDaoGenerator:genSources")
|
||||
|
@ -329,11 +329,11 @@ public class FetchActivityOperation extends AbstractMiBandOperation {
|
||||
|
||||
samples[minutes] = new MiBandActivitySample(
|
||||
timestampInSeconds,
|
||||
deviceId,
|
||||
userId,
|
||||
intensity & 0xff,
|
||||
steps & 0xff,
|
||||
category & 0xff,
|
||||
userId,
|
||||
deviceId,
|
||||
heartrate & 0xff);
|
||||
samples[minutes].setProvider(provider);
|
||||
|
||||
|
@ -72,7 +72,7 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth {
|
||||
|
||||
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
|
||||
for (OverlayRecord overlayRecord : overlayRecords) {
|
||||
overlayList.add(new PebbleHealthActivityOverlay(userId, deviceId, overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds - 1, overlayRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
overlayList.add(new PebbleHealthActivityOverlay(overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds - 1, deviceId, userId, 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(userId, deviceId, sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd - 1, sleepRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
overlayList.add(new PebbleHealthActivityOverlay(sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd - 1, deviceId, userId, sleepRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
}
|
||||
overlayDao.insertOrReplaceInTx(overlayList);
|
||||
} catch (Exception ex) {
|
||||
|
Loading…
Reference in New Issue
Block a user