From 76fd6178b48d1899ad15e1853b86678e6d906498 Mon Sep 17 00:00:00 2001 From: kingshy Date: Mon, 20 Oct 2014 18:52:06 -0700 Subject: [PATCH 1/6] first check dynamoDB for the night sleep score, if does not exist, recompute --- .../java/com/hello/suripu/app/SuripuApp.java | 2 +- .../app/resources/v1/TimelineResource.java | 29 +++++++++++++++-- .../hello/suripu/core/db/SleepScoreDAO.java | 31 ------------------- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/suripu-app/src/main/java/com/hello/suripu/app/SuripuApp.java b/suripu-app/src/main/java/com/hello/suripu/app/SuripuApp.java index 81b119e04..c109dff0a 100644 --- a/suripu-app/src/main/java/com/hello/suripu/app/SuripuApp.java +++ b/suripu-app/src/main/java/com/hello/suripu/app/SuripuApp.java @@ -222,7 +222,7 @@ public void run(final SuripuAppConfiguration configuration, final Environment en environment.addResource(new ScoresResource(trackerMotionDAO, sleepLabelDAO, sleepScoreDAO, aggregateSleepScoreDAODynamoDB, configuration.getScoreThreshold(), configuration.getSleepScoreVersion())); final SunData sunData = new SunData(); - environment.addResource(new TimelineResource(trackerMotionDAO, deviceDAO, sleepLabelDAO, sleepScoreDAO, configuration.getScoreThreshold(), sunData)); + environment.addResource(new TimelineResource(trackerMotionDAO, deviceDAO, sleepLabelDAO, sleepScoreDAO, aggregateSleepScoreDAODynamoDB, configuration.getScoreThreshold(), sunData)); environment.addResource(new TimeZoneResource(timeZoneHistoryDAODynamoDB, mergedAlarmInfoDynamoDB, deviceDAO)); environment.addResource(new AlarmResource(alarmDAODynamoDB, mergedAlarmInfoDynamoDB, deviceDAO)); diff --git a/suripu-app/src/main/java/com/hello/suripu/app/resources/v1/TimelineResource.java b/suripu-app/src/main/java/com/hello/suripu/app/resources/v1/TimelineResource.java index eecdbe363..a19054a32 100644 --- a/suripu-app/src/main/java/com/hello/suripu/app/resources/v1/TimelineResource.java +++ b/suripu-app/src/main/java/com/hello/suripu/app/resources/v1/TimelineResource.java @@ -2,10 +2,12 @@ import com.google.common.base.Optional; import com.google.common.collect.Lists; +import com.hello.suripu.core.db.AggregateSleepScoreDAODynamoDB; import com.hello.suripu.core.db.DeviceDAO; import com.hello.suripu.core.db.SleepLabelDAO; import com.hello.suripu.core.db.SleepScoreDAO; import com.hello.suripu.core.db.TrackerMotionDAO; +import com.hello.suripu.core.models.AggregateScore; import com.hello.suripu.core.models.Event; import com.hello.suripu.core.models.Insight; import com.hello.suripu.core.models.SensorReading; @@ -44,18 +46,21 @@ public class TimelineResource { private final DeviceDAO deviceDAO; private final SleepScoreDAO sleepScoreDAO; private final SleepLabelDAO sleepLabelDAO; + private final AggregateSleepScoreDAODynamoDB aggregateSleepScoreDAODynamoDB; private final int dateBucketPeriod; private final SunData sunData; public TimelineResource(final TrackerMotionDAO trackerMotionDAO, final DeviceDAO deviceDAO, final SleepLabelDAO sleepLabelDAO, final SleepScoreDAO sleepScoreDAO, + final AggregateSleepScoreDAODynamoDB aggregateSleepScoreDAODynamoDB, final int dateBucketPeriod, final SunData sunData) { this.trackerMotionDAO = trackerMotionDAO; this.deviceDAO = deviceDAO; this.sleepLabelDAO = sleepLabelDAO; this.sleepScoreDAO = sleepScoreDAO; + this.aggregateSleepScoreDAODynamoDB = aggregateSleepScoreDAODynamoDB; this.dateBucketPeriod = dateBucketPeriod; this.sunData = sunData; } @@ -149,9 +154,29 @@ public List getTimelines( final SleepStats sleepStats = TimelineUtils.computeStats(mergedSegments); final List reversed = Lists.reverse(mergedSegments); + // get scores - check dynamoDB first final int userOffsetMillis = trackerMotions.get(0).offsetMillis; - final Integer sleepScore = sleepScoreDAO.getSleepScoreForNight(accessToken.accountId, targetDate.withTimeAtStartOfDay(), - userOffsetMillis, this.dateBucketPeriod, sleepLabelDAO); + final String targetDateString = DateTimeUtil.dateToYmdString(targetDate); + + final AggregateScore targetDateScore = this.aggregateSleepScoreDAODynamoDB.getSingleScore(accessToken.accountId, targetDateString); + Integer sleepScore = targetDateScore.score; + + if (sleepScore == 0) { + // score may not have been computed yet, recompute + sleepScore = sleepScoreDAO.getSleepScoreForNight(accessToken.accountId, targetDate.withTimeAtStartOfDay(), + userOffsetMillis, this.dateBucketPeriod, sleepLabelDAO); + + final DateTime lastNight = new DateTime(DateTime.now(), DateTimeZone.UTC).withTimeAtStartOfDay().minusDays(1); + if (targetDate.isBefore(lastNight)) { + // write data to Dynamo if targetDate is old + this.aggregateSleepScoreDAODynamoDB.writeSingleScore( + new AggregateScore(accessToken.accountId, + sleepScore, + DateTimeUtil.dateToYmdString(targetDate.withTimeAtStartOfDay()), + targetDateScore.scoreType, targetDateScore.version)); + } + } + final String timeLineMessage = TimelineUtils.generateMessage(sleepStats); LOGGER.debug("Score for account_id = {} is {}", accessToken.accountId, sleepScore); diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/SleepScoreDAO.java b/suripu-core/src/main/java/com/hello/suripu/core/db/SleepScoreDAO.java index 33b99c31d..f0ca935b8 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/SleepScoreDAO.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/SleepScoreDAO.java @@ -168,37 +168,6 @@ public int getSleepScoreForNight(final Long accountID, final DateTime nightDate, } @Timed - public List getSleepScores(final Long accountID, - final List requiredDates, - final int dateBucketPeriod, - final TrackerMotionDAO trackerMotionDAO, - final SleepLabelDAO sleepLabelDAO, - final String version) { - - Collections.sort(requiredDates); - // get timezone offsets - final Map userOffsetMillis = trackerMotionDAO.getOffsetMillisForDates(accountID, requiredDates); - - final List scores = new ArrayList<>(); - - for (final DateTime targetDate : requiredDates) { - //TODO: looping bad, threads? - Integer timezoneOffset = null; - if (userOffsetMillis.containsKey(targetDate)) { - timezoneOffset = userOffsetMillis.get(targetDate); - } - - Integer score = this.getSleepScoreForNight(accountID, targetDate.withTimeAtStartOfDay(), timezoneOffset, dateBucketPeriod, sleepLabelDAO); - - final String dateString = DateTimeUtil.dateToYmdString(targetDate); - final AggregateScore aggregateScore = new AggregateScore(accountID, score, dateString, this.SCORE_TYPE, version); - - scores.add(aggregateScore); - } - - return scores; - } - public List getSleepScoreForNights(final Long accountID, final List requiredDates, final int dateBucketPeriod, From a7875becd692740525bd63711d370db3c592b6e9 Mon Sep 17 00:00:00 2001 From: kingshy Date: Tue, 21 Oct 2014 15:45:38 -0700 Subject: [PATCH 2/6] save raw dust counts --- .../hello/suripu/core/db/DeviceDataDAO.java | 8 +++- .../core/db/binders/BindDeviceData.java | 1 + .../db/mappers/DeviceDataBucketMapper.java | 1 + .../core/db/mappers/DeviceDataMapper.java | 1 + .../hello/suripu/core/models/DeviceData.java | 15 +++++- .../hello/suripu/core/db/BucketingTest.java | 4 +- .../suripu/core/models/DeviceDataTest.java | 47 +++++++++++++++++++ .../service/resources/ReceiveResource.java | 6 ++- 8 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java b/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java index 1f6a38bda..d6567f9b3 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java @@ -31,8 +31,10 @@ public abstract class DeviceDataDAO { @SqlUpdate("INSERT INTO device_sensors_master (account_id, device_id, ts, local_utc_ts, offset_millis, " + "ambient_temp, ambient_light, ambient_light_variance, ambient_light_peakiness, " + - "ambient_humidity, ambient_air_quality) VALUES(:account_id, :device_id, :ts, :local_utc_ts, :offset_millis, " + - ":ambient_temp, :ambient_light, :ambient_light_variance, :ambient_light_peakiness, :ambient_humidity, :ambient_air_quality)") + "ambient_humidity, ambient_air_quality, ambient_air_quality_raw) VALUES " + + "(:account_id, :device_id, :ts, :local_utc_ts, :offset_millis, " + + ":ambient_temp, :ambient_light, :ambient_light_variance, :ambient_light_peakiness, " + + ":ambient_humidity, :ambient_air_quality, :ambient_air_quality_raw)") public abstract void insert(@BindDeviceData final DeviceData deviceData); @RegisterMapper(DeviceDataMapper.class) @@ -62,6 +64,7 @@ public abstract ImmutableList getBetweenByLocalTime( "ROUND(AVG(ambient_light_peakiness)) as ambient_light_peakiness," + "ROUND(AVG(ambient_humidity)) as ambient_humidity," + "ROUND(AVG(ambient_air_quality)) as ambient_air_quality," + + "ROUND(AVG(ambient_air_quality_raw)) as ambient_air_quality_raw," + "ROUND(MIN(offset_millis)) as offset_millis," + "date_trunc('hour', ts) + (CAST(date_part('minute', ts) AS integer) / :slot_duration) * :slot_duration * interval '1 min' AS ts_bucket " + "FROM device_sensors_master " + @@ -164,6 +167,7 @@ public List generateTimeSerie( "AVG(ambient_temp) as ambient_temp, " + "AVG(ambient_humidity) as ambient_humidity, " + "AVG(ambient_air_quality) as ambient_air_quality, " + + "AVG(ambient_air_quality_raw) as ambient_air_quality_raw, " + "AVG(ambient_light) as ambient_light," + "AVG(ambient_light_variance) as ambient_light_variance," + "AVG(ambient_light_peakiness) as ambient_light_peakiness," + diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java b/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java index 04a574860..05e25b9c4 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java @@ -32,6 +32,7 @@ public void bind(final SQLStatement q, final BindDeviceData bind, final DeviceDa q.bind("ambient_light_peakiness", model.ambientLightPeakiness); q.bind("ambient_humidity", model.ambientHumidity); q.bind("ambient_air_quality", model.ambientAirQuality); + q.bind("ambient_air_quality_raw", model.ambientAirQualityRaw); q.bind("ts", model.dateTimeUTC); q.bind("local_utc_ts", model.dateTimeUTC.plusMillis(model.offsetMillis)); diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java index 6cf6546e3..1074940fe 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java @@ -18,6 +18,7 @@ public DeviceData map(int index, ResultSet r, StatementContext ctx) throws SQLEx r.getInt("ambient_temp"), r.getInt("ambient_humidity"), r.getInt("ambient_air_quality"), + r.getInt("ambient_air_quality_raw"), r.getInt("ambient_light"), r.getInt("ambient_light_variance"), r.getInt("ambient_light_peakiness"), diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java index 93eb9a7ad..54c1de8d9 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java @@ -18,6 +18,7 @@ public DeviceData map(int index, ResultSet r, StatementContext ctx) throws SQLEx r.getInt("ambient_temp"), r.getInt("ambient_humidity"), r.getInt("ambient_air_quality"), + r.getInt("ambient_air_quality_raw"), r.getInt("ambient_light"), r.getInt("ambient_light_variance"), r.getInt("ambient_light_peakiness"), diff --git a/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java b/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java index 35d308a4c..596d68637 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java @@ -28,6 +28,9 @@ public class DeviceData { @JsonProperty("ambient_air_quality") public final int ambientAirQuality; + @JsonProperty("ambient_air_quality_raw") + public final int ambientAirQualityRaw; + @JsonProperty("ambient_light") public final int ambientLight; @@ -49,6 +52,7 @@ public DeviceData( final int ambientTemperature, final int ambientHumidity, final int ambientAirQuality, + final int ambientAirQualityRaw, final int ambientLight, final int ambientLightVariance, final int ambientLightPeakiness, @@ -59,6 +63,7 @@ public DeviceData( this.ambientTemperature = ambientTemperature; this.ambientHumidity = ambientHumidity; this.ambientAirQuality = ambientAirQuality; + this.ambientAirQualityRaw = ambientAirQualityRaw; this.ambientLight = ambientLight; this.dateTimeUTC = dateTimeUTC; this.ambientLightVariance = ambientLightVariance; @@ -104,6 +109,7 @@ public static class Builder{ private int ambientTemperature; private int ambientHumidity; private int ambientAirQuality; + private int ambientAirQualityRaw; private int ambientLight; private int ambientLightVariance; private int ambientLightPeakiness; @@ -135,6 +141,11 @@ public Builder withAmbientAirQuality(final int ambientAirQuality, final int firm return this; } + public Builder withAmbientAirQualityRaw(final int ambientAirQuality) { + this.ambientAirQualityRaw = ambientAirQuality; + return this; + } + public Builder withAmbientLight(final int ambientLight){ this.ambientLight = ambientLight; return this; @@ -161,7 +172,7 @@ public Builder withOffsetMillis(final Integer offsetMillis){ } public DeviceData build(){ - return new DeviceData(this.accountId, this.deviceId, this.ambientTemperature, this.ambientHumidity, this.ambientAirQuality, this.ambientLight, this.ambientLightVariance, this.ambientLightPeakiness, this.dateTimeUTC, this.offsetMillis); + return new DeviceData(this.accountId, this.deviceId, this.ambientTemperature, this.ambientHumidity, this.ambientAirQuality, this.ambientAirQualityRaw, this.ambientLight, this.ambientLightVariance, this.ambientLightPeakiness, this.dateTimeUTC, this.offsetMillis); } @@ -177,6 +188,8 @@ public String toString() { .add("ambient_light", ambientLight) .add("ambient_light_variance", ambientLightVariance) .add("ambient_light_peakiness", ambientLightPeakiness) + .add("ambient_air_quality", ambientAirQuality) + .add("ambient_air_quality_raw", ambientAirQualityRaw) .add("dateTimeUTC", dateTimeUTC) .add("offset_millis", offsetMillis) .toString(); diff --git a/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java b/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java index 97d2ac74e..a68bbf137 100644 --- a/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java +++ b/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java @@ -29,7 +29,7 @@ public class BucketingTest { private Map generateMap(final DateTime startDate) { - final DeviceData deviceData = new DeviceData(999L, 111L, 222,333,444,555, 666, 777, startDate, 0); + final DeviceData deviceData = new DeviceData(999L, 111L, 222,333,444,555, 666, 777, 888, startDate, 0); final List deviceDataList = new ArrayList<>(); deviceDataList.add(deviceData); @@ -58,7 +58,7 @@ public void testEmptyMap() { public void testPopulateMap() { final Map map = Bucketing.generateEmptyMap(numberOfBuckets, startDate, slotDurationInMinutes); - final DeviceData deviceData = new DeviceData(999L, 111L, 222, 333, 444, 555, 666, 777, startDate, 0); + final DeviceData deviceData = new DeviceData(999L, 111L, 222, 333, 444, 555, 666, 777, 888, startDate, 0); final List deviceDataList = new ArrayList<>(); deviceDataList.add(deviceData); diff --git a/suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java b/suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java new file mode 100644 index 000000000..5b1b2e175 --- /dev/null +++ b/suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java @@ -0,0 +1,47 @@ +package com.hello.suripu.core.models; + +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * Created by kingshy on 10/20/14. + */ +public class DeviceDataTest { + private final static Logger LOGGER = LoggerFactory.getLogger(SleepScoreTest.class); + + @Test + public void testBuilder() { + final long timestamp = 1413862008 * 1000L; + final int temp = 2448; + final int humid = 3384; + final int dust = 1000; + final int light = 156; + final Long accountId = 3L; + + final DateTime roundedDateTime = new DateTime(timestamp, DateTimeZone.UTC).withSecondOfMinute(0); + final DeviceData.Builder builder = new DeviceData.Builder() + .withAccountId(accountId) + .withDeviceId(251278L) + .withAmbientTemperature(temp) + .withAmbientAirQuality(dust, 1) + .withAmbientAirQualityRaw(dust) + .withAmbientHumidity(humid) + .withAmbientLight(light) + .withAmbientLightVariance(14) + .withAmbientLightPeakiness(27) + .withOffsetMillis(-25200000) + .withDateTimeUTC(roundedDateTime); + + final DeviceData deviceData = builder.build(); + + assertThat(deviceData.ambientAirQuality, is(64924)); + } +} + + diff --git a/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java b/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java index f8adf3d0d..d18ffa98b 100644 --- a/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java +++ b/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java @@ -212,6 +212,7 @@ public byte[] morpheusProtobufReceiveEncrypted(final byte[] body) { .type(MediaType.TEXT_PLAIN_TYPE).build() ); } + LOGGER.debug("Received protobuf message {}", TextFormat.shortDebugString(data)); // get MAC address of morpheus @@ -225,7 +226,7 @@ public byte[] morpheusProtobufReceiveEncrypted(final byte[] body) { } - final String deviceName = deviceIdOptional.get(); + final String deviceName = deviceIdOptional.get().toUpperCase(); LOGGER.debug("Received valid protobuf {}", deviceName.toString()); LOGGER.debug("Received protobuf message {}", TextFormat.shortDebugString(data)); @@ -359,6 +360,7 @@ public byte[] morpheusProtobufReceiveEncrypted(final byte[] body) { .withDeviceId(pair.internalDeviceId) .withAmbientTemperature(data.getTemperature()) .withAmbientAirQuality(data.getDust(), data.getFirmwareVersion()) + .withAmbientAirQualityRaw(data.getDust()) .withAmbientHumidity(data.getHumidity()) .withAmbientLight(data.getLight()) .withAmbientLightVariance(data.getLightVariability()) @@ -480,6 +482,7 @@ public String morpheusProtobufReceive(final byte[] body) { .withDeviceId(pair.internalDeviceId) .withAmbientTemperature(data.getTemperature()) .withAmbientAirQuality(data.getDust(), data.getFirmwareVersion()) + .withAmbientAirQualityRaw(data.getDust()) .withAmbientHumidity(data.getHumidity()) .withAmbientLight(data.getLight()) .withAmbientLightVariance(data.getLightVariability()) @@ -569,6 +572,7 @@ public Response receiveSimpleData( .withDeviceId(pair.internalDeviceId) .withAmbientTemperature(temp) .withAmbientAirQuality(airQuality, 0) + .withAmbientAirQualityRaw(airQuality) .withAmbientHumidity(humidity) .withAmbientLight(light) .withOffsetMillis(offsetMillis) From 77fa8c15744b9c4def7c43f5ddb9a16218db811b Mon Sep 17 00:00:00 2001 From: kingshy Date: Tue, 21 Oct 2014 15:49:49 -0700 Subject: [PATCH 3/6] add new column to device_sensors --- sql/sensors/device_sensors/create.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/sensors/device_sensors/create.sql b/sql/sensors/device_sensors/create.sql index 80a1d53d3..4726ffca6 100644 --- a/sql/sensors/device_sensors/create.sql +++ b/sql/sensors/device_sensors/create.sql @@ -71,6 +71,7 @@ CREATE UNIQUE INDEX uniq_device_id_account_id_ts_on_par_default on device_sensor -- add new columns for additional light values (10/16/2014) ALTER TABLE device_sensors_master ADD COLUMN ambient_light_variance INTEGER DEFAULT 0; ALTER TABLE device_sensors_master ADD COLUMN ambient_light_peakiness INTEGER DEFAULT 0; +ALTER TABLE device_sensors_master ADD COLUMN ambient_air_quality_raw INTEGER DEFAULT 0; -- save raw counts -- store int instead of float (10/16/2014) ALTER TABLE device_sensors_master ALTER COLUMN ambient_temp SET DATA TYPE INTEGER; From 9f89dea73400b35e2f84a8d77983a67dd034816f Mon Sep 17 00:00:00 2001 From: kingshy Date: Wed, 22 Oct 2014 14:47:34 -0700 Subject: [PATCH 4/6] additional stats for dust --- .../hello/suripu/api/input/InputProtos.java | 858 +++++++++++------- .../src/main/resources/protos/Input.proto | 19 +- 2 files changed, 555 insertions(+), 322 deletions(-) diff --git a/suripu-api/src/main/java/com/hello/suripu/api/input/InputProtos.java b/suripu-api/src/main/java/com/hello/suripu/api/input/InputProtos.java index 3e9a7a5d8..e00dcdd54 100644 --- a/suripu-api/src/main/java/com/hello/suripu/api/input/InputProtos.java +++ b/suripu-api/src/main/java/com/hello/suripu/api/input/InputProtos.java @@ -20422,6 +20422,36 @@ public interface periodic_dataOrBuilder */ int getFirmwareVersion(); + // optional int32 dust_variability = 13; + /** + * optional int32 dust_variability = 13; + */ + boolean hasDustVariability(); + /** + * optional int32 dust_variability = 13; + */ + int getDustVariability(); + + // optional int32 dust_max = 14; + /** + * optional int32 dust_max = 14; + */ + boolean hasDustMax(); + /** + * optional int32 dust_max = 14; + */ + int getDustMax(); + + // optional int32 dust_min = 15; + /** + * optional int32 dust_min = 15; + */ + boolean hasDustMin(); + /** + * optional int32 dust_min = 15; + */ + int getDustMin(); + // repeated .hello.periodic_data.pill_data pills = 11; /** * repeated .hello.periodic_data.pill_data pills = 11; @@ -20564,18 +20594,33 @@ private periodic_data( break; } case 90: { - if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + if (!((mutable_bitField0_ & 0x00002000) == 0x00002000)) { pills_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000400; + mutable_bitField0_ |= 0x00002000; } pills_.add(input.readMessage(com.hello.suripu.api.input.InputProtos.periodic_data.pill_data.PARSER, extensionRegistry)); break; } case 98: { - bitField0_ |= 0x00000400; + bitField0_ |= 0x00002000; deviceId_ = input.readBytes(); break; } + case 104: { + bitField0_ |= 0x00000400; + dustVariability_ = input.readInt32(); + break; + } + case 112: { + bitField0_ |= 0x00000800; + dustMax_ = input.readInt32(); + break; + } + case 120: { + bitField0_ |= 0x00001000; + dustMin_ = input.readInt32(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -20584,7 +20629,7 @@ private periodic_data( throw new com.google.protobuf.InvalidProtocolBufferException( e.getMessage()).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + if (((mutable_bitField0_ & 0x00002000) == 0x00002000)) { pills_ = java.util.Collections.unmodifiableList(pills_); } this.unknownFields = unknownFields.build(); @@ -20621,82 +20666,78 @@ public com.google.protobuf.Parser getParserForType() { public interface pill_dataOrBuilder extends com.google.protobuf.MessageOrBuilder { - // optional string deviceId = 3; + // optional int32 firmwareVersion = 1; /** - * optional string deviceId = 3; + * optional int32 firmwareVersion = 1; * *
        * Be careful when copy paste, the index is not right :)
        * 
*/ - boolean hasDeviceId(); + boolean hasFirmwareVersion(); /** - * optional string deviceId = 3; + * optional int32 firmwareVersion = 1; * *
        * Be careful when copy paste, the index is not right :)
        * 
*/ + int getFirmwareVersion(); + + // optional bytes motionDataEncrypted = 2; + /** + * optional bytes motionDataEncrypted = 2; + */ + boolean hasMotionDataEncrypted(); + /** + * optional bytes motionDataEncrypted = 2; + */ + com.google.protobuf.ByteString getMotionDataEncrypted(); + + // optional string deviceId = 3; + /** + * optional string deviceId = 3; + */ + boolean hasDeviceId(); + /** + * optional string deviceId = 3; + */ java.lang.String getDeviceId(); /** * optional string deviceId = 3; - * - *
-       * Be careful when copy paste, the index is not right :)
-       * 
*/ com.google.protobuf.ByteString getDeviceIdBytes(); - // optional int32 batteryLevel = 9; + // optional int32 batteryLevel = 4; /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ boolean hasBatteryLevel(); /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ int getBatteryLevel(); - // optional int32 uptime = 10; + // optional int32 uptime = 5; /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ boolean hasUptime(); /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ int getUptime(); - // optional int32 motionData = 11; + // optional int32 motionData = 6; /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ boolean hasMotionData(); /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ int getMotionData(); - - // optional bytes motionDataEncrypted = 2; - /** - * optional bytes motionDataEncrypted = 2; - */ - boolean hasMotionDataEncrypted(); - /** - * optional bytes motionDataEncrypted = 2; - */ - com.google.protobuf.ByteString getMotionDataEncrypted(); - - // optional int32 firmwareVersion = 1; - /** - * optional int32 firmwareVersion = 1; - */ - boolean hasFirmwareVersion(); - /** - * optional int32 firmwareVersion = 1; - */ - int getFirmwareVersion(); } /** * Protobuf type {@code hello.periodic_data.pill_data} @@ -20750,32 +20791,32 @@ private pill_data( break; } case 8: { - bitField0_ |= 0x00000020; + bitField0_ |= 0x00000001; firmwareVersion_ = input.readInt32(); break; } case 18: { - bitField0_ |= 0x00000010; + bitField0_ |= 0x00000002; motionDataEncrypted_ = input.readBytes(); break; } case 26: { - bitField0_ |= 0x00000001; + bitField0_ |= 0x00000004; deviceId_ = input.readBytes(); break; } - case 72: { - bitField0_ |= 0x00000002; + case 32: { + bitField0_ |= 0x00000008; batteryLevel_ = input.readInt32(); break; } - case 80: { - bitField0_ |= 0x00000004; + case 40: { + bitField0_ |= 0x00000010; uptime_ = input.readInt32(); break; } - case 88: { - bitField0_ |= 0x00000008; + case 48: { + bitField0_ |= 0x00000020; motionData_ = input.readInt32(); break; } @@ -20819,26 +20860,58 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional string deviceId = 3; - public static final int DEVICEID_FIELD_NUMBER = 3; - private java.lang.Object deviceId_; + // optional int32 firmwareVersion = 1; + public static final int FIRMWAREVERSION_FIELD_NUMBER = 1; + private int firmwareVersion_; /** - * optional string deviceId = 3; + * optional int32 firmwareVersion = 1; * *
        * Be careful when copy paste, the index is not right :)
        * 
*/ - public boolean hasDeviceId() { + public boolean hasFirmwareVersion() { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * optional string deviceId = 3; + * optional int32 firmwareVersion = 1; * *
        * Be careful when copy paste, the index is not right :)
        * 
*/ + public int getFirmwareVersion() { + return firmwareVersion_; + } + + // optional bytes motionDataEncrypted = 2; + public static final int MOTIONDATAENCRYPTED_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString motionDataEncrypted_; + /** + * optional bytes motionDataEncrypted = 2; + */ + public boolean hasMotionDataEncrypted() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional bytes motionDataEncrypted = 2; + */ + public com.google.protobuf.ByteString getMotionDataEncrypted() { + return motionDataEncrypted_; + } + + // optional string deviceId = 3; + public static final int DEVICEID_FIELD_NUMBER = 3; + private java.lang.Object deviceId_; + /** + * optional string deviceId = 3; + */ + public boolean hasDeviceId() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string deviceId = 3; + */ public java.lang.String getDeviceId() { java.lang.Object ref = deviceId_; if (ref instanceof java.lang.String) { @@ -20855,10 +20928,6 @@ public java.lang.String getDeviceId() { } /** * optional string deviceId = 3; - * - *
-       * Be careful when copy paste, the index is not right :)
-       * 
*/ public com.google.protobuf.ByteString getDeviceIdBytes() { @@ -20874,93 +20943,61 @@ public java.lang.String getDeviceId() { } } - // optional int32 batteryLevel = 9; - public static final int BATTERYLEVEL_FIELD_NUMBER = 9; + // optional int32 batteryLevel = 4; + public static final int BATTERYLEVEL_FIELD_NUMBER = 4; private int batteryLevel_; /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ public boolean hasBatteryLevel() { - return ((bitField0_ & 0x00000002) == 0x00000002); + return ((bitField0_ & 0x00000008) == 0x00000008); } /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ public int getBatteryLevel() { return batteryLevel_; } - // optional int32 uptime = 10; - public static final int UPTIME_FIELD_NUMBER = 10; + // optional int32 uptime = 5; + public static final int UPTIME_FIELD_NUMBER = 5; private int uptime_; /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ public boolean hasUptime() { - return ((bitField0_ & 0x00000004) == 0x00000004); + return ((bitField0_ & 0x00000010) == 0x00000010); } /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ public int getUptime() { return uptime_; } - // optional int32 motionData = 11; - public static final int MOTIONDATA_FIELD_NUMBER = 11; + // optional int32 motionData = 6; + public static final int MOTIONDATA_FIELD_NUMBER = 6; private int motionData_; /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ public boolean hasMotionData() { - return ((bitField0_ & 0x00000008) == 0x00000008); + return ((bitField0_ & 0x00000020) == 0x00000020); } /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ public int getMotionData() { return motionData_; } - // optional bytes motionDataEncrypted = 2; - public static final int MOTIONDATAENCRYPTED_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString motionDataEncrypted_; - /** - * optional bytes motionDataEncrypted = 2; - */ - public boolean hasMotionDataEncrypted() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional bytes motionDataEncrypted = 2; - */ - public com.google.protobuf.ByteString getMotionDataEncrypted() { - return motionDataEncrypted_; - } - - // optional int32 firmwareVersion = 1; - public static final int FIRMWAREVERSION_FIELD_NUMBER = 1; - private int firmwareVersion_; - /** - * optional int32 firmwareVersion = 1; - */ - public boolean hasFirmwareVersion() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional int32 firmwareVersion = 1; - */ - public int getFirmwareVersion() { - return firmwareVersion_; - } - private void initFields() { + firmwareVersion_ = 0; + motionDataEncrypted_ = com.google.protobuf.ByteString.EMPTY; deviceId_ = ""; batteryLevel_ = 0; uptime_ = 0; motionData_ = 0; - motionDataEncrypted_ = com.google.protobuf.ByteString.EMPTY; - firmwareVersion_ = 0; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -20974,23 +21011,23 @@ public final boolean isInitialized() { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - if (((bitField0_ & 0x00000020) == 0x00000020)) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeInt32(1, firmwareVersion_); } - if (((bitField0_ & 0x00000010) == 0x00000010)) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeBytes(2, motionDataEncrypted_); } - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeBytes(3, getDeviceIdBytes()); } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt32(9, batteryLevel_); + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeInt32(4, batteryLevel_); } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeInt32(10, uptime_); + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeInt32(5, uptime_); } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeInt32(11, motionData_); + if (((bitField0_ & 0x00000020) == 0x00000020)) { + output.writeInt32(6, motionData_); } getUnknownFields().writeTo(output); } @@ -21001,29 +21038,29 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (((bitField0_ & 0x00000020) == 0x00000020)) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(1, firmwareVersion_); } - if (((bitField0_ & 0x00000010) == 0x00000010)) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, motionDataEncrypted_); } - if (((bitField0_ & 0x00000001) == 0x00000001)) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(3, getDeviceIdBytes()); } - if (((bitField0_ & 0x00000002) == 0x00000002)) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(9, batteryLevel_); + .computeInt32Size(4, batteryLevel_); } - if (((bitField0_ & 0x00000004) == 0x00000004)) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(10, uptime_); + .computeInt32Size(5, uptime_); } - if (((bitField0_ & 0x00000008) == 0x00000008)) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(11, motionData_); + .computeInt32Size(6, motionData_); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -21141,17 +21178,17 @@ private static Builder create() { public Builder clear() { super.clear(); - deviceId_ = ""; + firmwareVersion_ = 0; bitField0_ = (bitField0_ & ~0x00000001); - batteryLevel_ = 0; + motionDataEncrypted_ = com.google.protobuf.ByteString.EMPTY; bitField0_ = (bitField0_ & ~0x00000002); - uptime_ = 0; + deviceId_ = ""; bitField0_ = (bitField0_ & ~0x00000004); - motionData_ = 0; + batteryLevel_ = 0; bitField0_ = (bitField0_ & ~0x00000008); - motionDataEncrypted_ = com.google.protobuf.ByteString.EMPTY; + uptime_ = 0; bitField0_ = (bitField0_ & ~0x00000010); - firmwareVersion_ = 0; + motionData_ = 0; bitField0_ = (bitField0_ & ~0x00000020); return this; } @@ -21184,27 +21221,27 @@ public com.hello.suripu.api.input.InputProtos.periodic_data.pill_data buildParti if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } - result.deviceId_ = deviceId_; + result.firmwareVersion_ = firmwareVersion_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { to_bitField0_ |= 0x00000002; } - result.batteryLevel_ = batteryLevel_; + result.motionDataEncrypted_ = motionDataEncrypted_; if (((from_bitField0_ & 0x00000004) == 0x00000004)) { to_bitField0_ |= 0x00000004; } - result.uptime_ = uptime_; + result.deviceId_ = deviceId_; if (((from_bitField0_ & 0x00000008) == 0x00000008)) { to_bitField0_ |= 0x00000008; } - result.motionData_ = motionData_; + result.batteryLevel_ = batteryLevel_; if (((from_bitField0_ & 0x00000010) == 0x00000010)) { to_bitField0_ |= 0x00000010; } - result.motionDataEncrypted_ = motionDataEncrypted_; + result.uptime_ = uptime_; if (((from_bitField0_ & 0x00000020) == 0x00000020)) { to_bitField0_ |= 0x00000020; } - result.firmwareVersion_ = firmwareVersion_; + result.motionData_ = motionData_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -21221,8 +21258,14 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(com.hello.suripu.api.input.InputProtos.periodic_data.pill_data other) { if (other == com.hello.suripu.api.input.InputProtos.periodic_data.pill_data.getDefaultInstance()) return this; + if (other.hasFirmwareVersion()) { + setFirmwareVersion(other.getFirmwareVersion()); + } + if (other.hasMotionDataEncrypted()) { + setMotionDataEncrypted(other.getMotionDataEncrypted()); + } if (other.hasDeviceId()) { - bitField0_ |= 0x00000001; + bitField0_ |= 0x00000004; deviceId_ = other.deviceId_; onChanged(); } @@ -21235,12 +21278,6 @@ public Builder mergeFrom(com.hello.suripu.api.input.InputProtos.periodic_data.pi if (other.hasMotionData()) { setMotionData(other.getMotionData()); } - if (other.hasMotionDataEncrypted()) { - setMotionDataEncrypted(other.getMotionDataEncrypted()); - } - if (other.hasFirmwareVersion()) { - setFirmwareVersion(other.getFirmwareVersion()); - } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -21248,44 +21285,121 @@ public Builder mergeFrom(com.hello.suripu.api.input.InputProtos.periodic_data.pi public final boolean isInitialized() { return true; } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.hello.suripu.api.input.InputProtos.periodic_data.pill_data parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.hello.suripu.api.input.InputProtos.periodic_data.pill_data) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.hello.suripu.api.input.InputProtos.periodic_data.pill_data parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.hello.suripu.api.input.InputProtos.periodic_data.pill_data) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // optional int32 firmwareVersion = 1; + private int firmwareVersion_ ; + /** + * optional int32 firmwareVersion = 1; + * + *
+         * Be careful when copy paste, the index is not right :)
+         * 
+ */ + public boolean hasFirmwareVersion() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int32 firmwareVersion = 1; + * + *
+         * Be careful when copy paste, the index is not right :)
+         * 
+ */ + public int getFirmwareVersion() { + return firmwareVersion_; + } + /** + * optional int32 firmwareVersion = 1; + * + *
+         * Be careful when copy paste, the index is not right :)
+         * 
+ */ + public Builder setFirmwareVersion(int value) { + bitField0_ |= 0x00000001; + firmwareVersion_ = value; + onChanged(); + return this; + } + /** + * optional int32 firmwareVersion = 1; + * + *
+         * Be careful when copy paste, the index is not right :)
+         * 
+ */ + public Builder clearFirmwareVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + firmwareVersion_ = 0; + onChanged(); + return this; + } + + // optional bytes motionDataEncrypted = 2; + private com.google.protobuf.ByteString motionDataEncrypted_ = com.google.protobuf.ByteString.EMPTY; + /** + * optional bytes motionDataEncrypted = 2; + */ + public boolean hasMotionDataEncrypted() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional bytes motionDataEncrypted = 2; + */ + public com.google.protobuf.ByteString getMotionDataEncrypted() { + return motionDataEncrypted_; + } + /** + * optional bytes motionDataEncrypted = 2; + */ + public Builder setMotionDataEncrypted(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + motionDataEncrypted_ = value; + onChanged(); + return this; + } + /** + * optional bytes motionDataEncrypted = 2; + */ + public Builder clearMotionDataEncrypted() { + bitField0_ = (bitField0_ & ~0x00000002); + motionDataEncrypted_ = getDefaultInstance().getMotionDataEncrypted(); + onChanged(); return this; } - private int bitField0_; // optional string deviceId = 3; private java.lang.Object deviceId_ = ""; /** * optional string deviceId = 3; - * - *
-         * Be careful when copy paste, the index is not right :)
-         * 
*/ public boolean hasDeviceId() { - return ((bitField0_ & 0x00000001) == 0x00000001); + return ((bitField0_ & 0x00000004) == 0x00000004); } /** * optional string deviceId = 3; - * - *
-         * Be careful when copy paste, the index is not right :)
-         * 
*/ public java.lang.String getDeviceId() { java.lang.Object ref = deviceId_; @@ -21300,10 +21414,6 @@ public java.lang.String getDeviceId() { } /** * optional string deviceId = 3; - * - *
-         * Be careful when copy paste, the index is not right :)
-         * 
*/ public com.google.protobuf.ByteString getDeviceIdBytes() { @@ -21320,216 +21430,135 @@ public java.lang.String getDeviceId() { } /** * optional string deviceId = 3; - * - *
-         * Be careful when copy paste, the index is not right :)
-         * 
*/ public Builder setDeviceId( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - bitField0_ |= 0x00000001; + bitField0_ |= 0x00000004; deviceId_ = value; onChanged(); return this; } /** * optional string deviceId = 3; - * - *
-         * Be careful when copy paste, the index is not right :)
-         * 
*/ public Builder clearDeviceId() { - bitField0_ = (bitField0_ & ~0x00000001); + bitField0_ = (bitField0_ & ~0x00000004); deviceId_ = getDefaultInstance().getDeviceId(); onChanged(); return this; } /** * optional string deviceId = 3; - * - *
-         * Be careful when copy paste, the index is not right :)
-         * 
*/ public Builder setDeviceIdBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } - bitField0_ |= 0x00000001; + bitField0_ |= 0x00000004; deviceId_ = value; onChanged(); return this; } - // optional int32 batteryLevel = 9; + // optional int32 batteryLevel = 4; private int batteryLevel_ ; /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ public boolean hasBatteryLevel() { - return ((bitField0_ & 0x00000002) == 0x00000002); + return ((bitField0_ & 0x00000008) == 0x00000008); } /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ public int getBatteryLevel() { return batteryLevel_; } /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ public Builder setBatteryLevel(int value) { - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000008; batteryLevel_ = value; onChanged(); return this; } /** - * optional int32 batteryLevel = 9; + * optional int32 batteryLevel = 4; */ public Builder clearBatteryLevel() { - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000008); batteryLevel_ = 0; onChanged(); return this; } - // optional int32 uptime = 10; + // optional int32 uptime = 5; private int uptime_ ; /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ public boolean hasUptime() { - return ((bitField0_ & 0x00000004) == 0x00000004); + return ((bitField0_ & 0x00000010) == 0x00000010); } /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ public int getUptime() { return uptime_; } /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ public Builder setUptime(int value) { - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000010; uptime_ = value; onChanged(); return this; } /** - * optional int32 uptime = 10; + * optional int32 uptime = 5; */ public Builder clearUptime() { - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000010); uptime_ = 0; onChanged(); return this; } - // optional int32 motionData = 11; + // optional int32 motionData = 6; private int motionData_ ; /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ public boolean hasMotionData() { - return ((bitField0_ & 0x00000008) == 0x00000008); + return ((bitField0_ & 0x00000020) == 0x00000020); } /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ public int getMotionData() { return motionData_; } /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ public Builder setMotionData(int value) { - bitField0_ |= 0x00000008; + bitField0_ |= 0x00000020; motionData_ = value; onChanged(); return this; } /** - * optional int32 motionData = 11; + * optional int32 motionData = 6; */ public Builder clearMotionData() { - bitField0_ = (bitField0_ & ~0x00000008); - motionData_ = 0; - onChanged(); - return this; - } - - // optional bytes motionDataEncrypted = 2; - private com.google.protobuf.ByteString motionDataEncrypted_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes motionDataEncrypted = 2; - */ - public boolean hasMotionDataEncrypted() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * optional bytes motionDataEncrypted = 2; - */ - public com.google.protobuf.ByteString getMotionDataEncrypted() { - return motionDataEncrypted_; - } - /** - * optional bytes motionDataEncrypted = 2; - */ - public Builder setMotionDataEncrypted(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000010; - motionDataEncrypted_ = value; - onChanged(); - return this; - } - /** - * optional bytes motionDataEncrypted = 2; - */ - public Builder clearMotionDataEncrypted() { - bitField0_ = (bitField0_ & ~0x00000010); - motionDataEncrypted_ = getDefaultInstance().getMotionDataEncrypted(); - onChanged(); - return this; - } - - // optional int32 firmwareVersion = 1; - private int firmwareVersion_ ; - /** - * optional int32 firmwareVersion = 1; - */ - public boolean hasFirmwareVersion() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional int32 firmwareVersion = 1; - */ - public int getFirmwareVersion() { - return firmwareVersion_; - } - /** - * optional int32 firmwareVersion = 1; - */ - public Builder setFirmwareVersion(int value) { - bitField0_ |= 0x00000020; - firmwareVersion_ = value; - onChanged(); - return this; - } - /** - * optional int32 firmwareVersion = 1; - */ - public Builder clearFirmwareVersion() { bitField0_ = (bitField0_ & ~0x00000020); - firmwareVersion_ = 0; + motionData_ = 0; onChanged(); return this; } @@ -21733,6 +21762,54 @@ public int getFirmwareVersion() { return firmwareVersion_; } + // optional int32 dust_variability = 13; + public static final int DUST_VARIABILITY_FIELD_NUMBER = 13; + private int dustVariability_; + /** + * optional int32 dust_variability = 13; + */ + public boolean hasDustVariability() { + return ((bitField0_ & 0x00000400) == 0x00000400); + } + /** + * optional int32 dust_variability = 13; + */ + public int getDustVariability() { + return dustVariability_; + } + + // optional int32 dust_max = 14; + public static final int DUST_MAX_FIELD_NUMBER = 14; + private int dustMax_; + /** + * optional int32 dust_max = 14; + */ + public boolean hasDustMax() { + return ((bitField0_ & 0x00000800) == 0x00000800); + } + /** + * optional int32 dust_max = 14; + */ + public int getDustMax() { + return dustMax_; + } + + // optional int32 dust_min = 15; + public static final int DUST_MIN_FIELD_NUMBER = 15; + private int dustMin_; + /** + * optional int32 dust_min = 15; + */ + public boolean hasDustMin() { + return ((bitField0_ & 0x00001000) == 0x00001000); + } + /** + * optional int32 dust_min = 15; + */ + public int getDustMin() { + return dustMin_; + } + // repeated .hello.periodic_data.pill_data pills = 11; public static final int PILLS_FIELD_NUMBER = 11; private java.util.List pills_; @@ -21776,7 +21853,7 @@ public com.hello.suripu.api.input.InputProtos.periodic_data.pill_dataOrBuilder g * optional string device_id = 12; */ public boolean hasDeviceId() { - return ((bitField0_ & 0x00000400) == 0x00000400); + return ((bitField0_ & 0x00002000) == 0x00002000); } /** * optional string device_id = 12; @@ -21823,6 +21900,9 @@ private void initFields() { lightVariability_ = 0; lightTonality_ = 0; firmwareVersion_ = 0; + dustVariability_ = 0; + dustMax_ = 0; + dustMin_ = 0; pills_ = java.util.Collections.emptyList(); deviceId_ = ""; } @@ -21871,9 +21951,18 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < pills_.size(); i++) { output.writeMessage(11, pills_.get(i)); } - if (((bitField0_ & 0x00000400) == 0x00000400)) { + if (((bitField0_ & 0x00002000) == 0x00002000)) { output.writeBytes(12, getDeviceIdBytes()); } + if (((bitField0_ & 0x00000400) == 0x00000400)) { + output.writeInt32(13, dustVariability_); + } + if (((bitField0_ & 0x00000800) == 0x00000800)) { + output.writeInt32(14, dustMax_); + } + if (((bitField0_ & 0x00001000) == 0x00001000)) { + output.writeInt32(15, dustMin_); + } getUnknownFields().writeTo(output); } @@ -21927,10 +22016,22 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(11, pills_.get(i)); } - if (((bitField0_ & 0x00000400) == 0x00000400)) { + if (((bitField0_ & 0x00002000) == 0x00002000)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(12, getDeviceIdBytes()); } + if (((bitField0_ & 0x00000400) == 0x00000400)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(13, dustVariability_); + } + if (((bitField0_ & 0x00000800) == 0x00000800)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(14, dustMax_); + } + if (((bitField0_ & 0x00001000) == 0x00001000)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(15, dustMin_); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -22068,14 +22169,20 @@ public Builder clear() { bitField0_ = (bitField0_ & ~0x00000100); firmwareVersion_ = 0; bitField0_ = (bitField0_ & ~0x00000200); + dustVariability_ = 0; + bitField0_ = (bitField0_ & ~0x00000400); + dustMax_ = 0; + bitField0_ = (bitField0_ & ~0x00000800); + dustMin_ = 0; + bitField0_ = (bitField0_ & ~0x00001000); if (pillsBuilder_ == null) { pills_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00002000); } else { pillsBuilder_.clear(); } deviceId_ = ""; - bitField0_ = (bitField0_ & ~0x00000800); + bitField0_ = (bitField0_ & ~0x00004000); return this; } @@ -22144,17 +22251,29 @@ public com.hello.suripu.api.input.InputProtos.periodic_data buildPartial() { to_bitField0_ |= 0x00000200; } result.firmwareVersion_ = firmwareVersion_; + if (((from_bitField0_ & 0x00000400) == 0x00000400)) { + to_bitField0_ |= 0x00000400; + } + result.dustVariability_ = dustVariability_; + if (((from_bitField0_ & 0x00000800) == 0x00000800)) { + to_bitField0_ |= 0x00000800; + } + result.dustMax_ = dustMax_; + if (((from_bitField0_ & 0x00001000) == 0x00001000)) { + to_bitField0_ |= 0x00001000; + } + result.dustMin_ = dustMin_; if (pillsBuilder_ == null) { - if (((bitField0_ & 0x00000400) == 0x00000400)) { + if (((bitField0_ & 0x00002000) == 0x00002000)) { pills_ = java.util.Collections.unmodifiableList(pills_); - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00002000); } result.pills_ = pills_; } else { result.pills_ = pillsBuilder_.build(); } - if (((from_bitField0_ & 0x00000800) == 0x00000800)) { - to_bitField0_ |= 0x00000400; + if (((from_bitField0_ & 0x00004000) == 0x00004000)) { + to_bitField0_ |= 0x00002000; } result.deviceId_ = deviceId_; result.bitField0_ = to_bitField0_; @@ -22205,11 +22324,20 @@ public Builder mergeFrom(com.hello.suripu.api.input.InputProtos.periodic_data ot if (other.hasFirmwareVersion()) { setFirmwareVersion(other.getFirmwareVersion()); } + if (other.hasDustVariability()) { + setDustVariability(other.getDustVariability()); + } + if (other.hasDustMax()) { + setDustMax(other.getDustMax()); + } + if (other.hasDustMin()) { + setDustMin(other.getDustMin()); + } if (pillsBuilder_ == null) { if (!other.pills_.isEmpty()) { if (pills_.isEmpty()) { pills_ = other.pills_; - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00002000); } else { ensurePillsIsMutable(); pills_.addAll(other.pills_); @@ -22222,7 +22350,7 @@ public Builder mergeFrom(com.hello.suripu.api.input.InputProtos.periodic_data ot pillsBuilder_.dispose(); pillsBuilder_ = null; pills_ = other.pills_; - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00002000); pillsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPillsFieldBuilder() : null; @@ -22232,7 +22360,7 @@ public Builder mergeFrom(com.hello.suripu.api.input.InputProtos.periodic_data ot } } if (other.hasDeviceId()) { - bitField0_ |= 0x00000800; + bitField0_ |= 0x00004000; deviceId_ = other.deviceId_; onChanged(); } @@ -22637,13 +22765,112 @@ public Builder clearFirmwareVersion() { return this; } + // optional int32 dust_variability = 13; + private int dustVariability_ ; + /** + * optional int32 dust_variability = 13; + */ + public boolean hasDustVariability() { + return ((bitField0_ & 0x00000400) == 0x00000400); + } + /** + * optional int32 dust_variability = 13; + */ + public int getDustVariability() { + return dustVariability_; + } + /** + * optional int32 dust_variability = 13; + */ + public Builder setDustVariability(int value) { + bitField0_ |= 0x00000400; + dustVariability_ = value; + onChanged(); + return this; + } + /** + * optional int32 dust_variability = 13; + */ + public Builder clearDustVariability() { + bitField0_ = (bitField0_ & ~0x00000400); + dustVariability_ = 0; + onChanged(); + return this; + } + + // optional int32 dust_max = 14; + private int dustMax_ ; + /** + * optional int32 dust_max = 14; + */ + public boolean hasDustMax() { + return ((bitField0_ & 0x00000800) == 0x00000800); + } + /** + * optional int32 dust_max = 14; + */ + public int getDustMax() { + return dustMax_; + } + /** + * optional int32 dust_max = 14; + */ + public Builder setDustMax(int value) { + bitField0_ |= 0x00000800; + dustMax_ = value; + onChanged(); + return this; + } + /** + * optional int32 dust_max = 14; + */ + public Builder clearDustMax() { + bitField0_ = (bitField0_ & ~0x00000800); + dustMax_ = 0; + onChanged(); + return this; + } + + // optional int32 dust_min = 15; + private int dustMin_ ; + /** + * optional int32 dust_min = 15; + */ + public boolean hasDustMin() { + return ((bitField0_ & 0x00001000) == 0x00001000); + } + /** + * optional int32 dust_min = 15; + */ + public int getDustMin() { + return dustMin_; + } + /** + * optional int32 dust_min = 15; + */ + public Builder setDustMin(int value) { + bitField0_ |= 0x00001000; + dustMin_ = value; + onChanged(); + return this; + } + /** + * optional int32 dust_min = 15; + */ + public Builder clearDustMin() { + bitField0_ = (bitField0_ & ~0x00001000); + dustMin_ = 0; + onChanged(); + return this; + } + // repeated .hello.periodic_data.pill_data pills = 11; private java.util.List pills_ = java.util.Collections.emptyList(); private void ensurePillsIsMutable() { - if (!((bitField0_ & 0x00000400) == 0x00000400)) { + if (!((bitField0_ & 0x00002000) == 0x00002000)) { pills_ = new java.util.ArrayList(pills_); - bitField0_ |= 0x00000400; + bitField0_ |= 0x00002000; } } @@ -22792,7 +23019,7 @@ public Builder addAllPills( public Builder clearPills() { if (pillsBuilder_ == null) { pills_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00002000); onChanged(); } else { pillsBuilder_.clear(); @@ -22869,7 +23096,7 @@ public com.hello.suripu.api.input.InputProtos.periodic_data.pill_data.Builder ad pillsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< com.hello.suripu.api.input.InputProtos.periodic_data.pill_data, com.hello.suripu.api.input.InputProtos.periodic_data.pill_data.Builder, com.hello.suripu.api.input.InputProtos.periodic_data.pill_dataOrBuilder>( pills_, - ((bitField0_ & 0x00000400) == 0x00000400), + ((bitField0_ & 0x00002000) == 0x00002000), getParentForChildren(), isClean()); pills_ = null; @@ -22883,7 +23110,7 @@ public com.hello.suripu.api.input.InputProtos.periodic_data.pill_data.Builder ad * optional string device_id = 12; */ public boolean hasDeviceId() { - return ((bitField0_ & 0x00000800) == 0x00000800); + return ((bitField0_ & 0x00004000) == 0x00004000); } /** * optional string device_id = 12; @@ -22923,7 +23150,7 @@ public Builder setDeviceId( if (value == null) { throw new NullPointerException(); } - bitField0_ |= 0x00000800; + bitField0_ |= 0x00004000; deviceId_ = value; onChanged(); return this; @@ -22932,7 +23159,7 @@ public Builder setDeviceId( * optional string device_id = 12; */ public Builder clearDeviceId() { - bitField0_ = (bitField0_ & ~0x00000800); + bitField0_ = (bitField0_ & ~0x00004000); deviceId_ = getDefaultInstance().getDeviceId(); onChanged(); return this; @@ -22945,7 +23172,7 @@ public Builder setDeviceIdBytes( if (value == null) { throw new NullPointerException(); } - bitField0_ |= 0x00000800; + bitField0_ |= 0x00004000; deviceId_ = value; onChanged(); return this; @@ -23185,19 +23412,20 @@ public Builder setDeviceIdBytes( "Data\"\214\001\n\nEventBatch\022+\n\006events\030\001 \003(\0132\033.he" + "llo.EventBatch.EventItem\032Q\n\tEventItem\022\027\n" + "\017start_timestamp\030\001 \001(\003\022\025\n\rend_timestamp\030" + - "\002 \001(\003\022\024\n\014offsetMillis\030\003 \001(\005\"\240\003\n\rperiodic" + + "\002 \001(\003\022\024\n\014offsetMillis\030\003 \001(\005\"\336\003\n\rperiodic" + "_data\022\021\n\tunix_time\030\001 \001(\005\022\r\n\005light\030\002 \001(\005\022" + "\023\n\013temperature\030\003 \001(\005\022\020\n\010humidity\030\004 \001(\005\022\014" + "\n\004dust\030\005 \001(\005\022\014\n\004name\030\006 \001(\t\022\013\n\003mac\030\007 \001(\014\022" + "\031\n\021light_variability\030\010 \001(\005\022\026\n\016light_tona" + - "lity\030\t \001(\005\022\030\n\020firmware_version\030\n \001(\005\022-\n\005", - "pills\030\013 \003(\0132\036.hello.periodic_data.pill_d" + - "ata\022\021\n\tdevice_id\030\014 \001(\t\032\215\001\n\tpill_data\022\020\n\010" + - "deviceId\030\003 \001(\t\022\024\n\014batteryLevel\030\t \001(\005\022\016\n\006" + - "uptime\030\n \001(\005\022\022\n\nmotionData\030\013 \001(\005\022\033\n\023moti" + - "onDataEncrypted\030\002 \001(\014\022\027\n\017firmwareVersion" + - "\030\001 \001(\005B)\n\032com.hello.suripu.api.inputB\013In" + - "putProtos" + "lity\030\t \001(\005\022\030\n\020firmware_version\030\n \001(\005\022\030\n\020", + "dust_variability\030\r \001(\005\022\020\n\010dust_max\030\016 \001(\005" + + "\022\020\n\010dust_min\030\017 \001(\005\022-\n\005pills\030\013 \003(\0132\036.hell" + + "o.periodic_data.pill_data\022\021\n\tdevice_id\030\014" + + " \001(\t\032\215\001\n\tpill_data\022\027\n\017firmwareVersion\030\001 " + + "\001(\005\022\033\n\023motionDataEncrypted\030\002 \001(\014\022\020\n\010devi" + + "ceId\030\003 \001(\t\022\024\n\014batteryLevel\030\004 \001(\005\022\016\n\006upti" + + "me\030\005 \001(\005\022\022\n\nmotionData\030\006 \001(\005B)\n\032com.hell" + + "o.suripu.api.inputB\013InputProtos" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -23353,13 +23581,13 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_hello_periodic_data_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_hello_periodic_data_descriptor, - new java.lang.String[] { "UnixTime", "Light", "Temperature", "Humidity", "Dust", "Name", "Mac", "LightVariability", "LightTonality", "FirmwareVersion", "Pills", "DeviceId", }); + new java.lang.String[] { "UnixTime", "Light", "Temperature", "Humidity", "Dust", "Name", "Mac", "LightVariability", "LightTonality", "FirmwareVersion", "DustVariability", "DustMax", "DustMin", "Pills", "DeviceId", }); internal_static_hello_periodic_data_pill_data_descriptor = internal_static_hello_periodic_data_descriptor.getNestedTypes().get(0); internal_static_hello_periodic_data_pill_data_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_hello_periodic_data_pill_data_descriptor, - new java.lang.String[] { "DeviceId", "BatteryLevel", "Uptime", "MotionData", "MotionDataEncrypted", "FirmwareVersion", }); + new java.lang.String[] { "FirmwareVersion", "MotionDataEncrypted", "DeviceId", "BatteryLevel", "Uptime", "MotionData", }); return null; } }; diff --git a/suripu-api/src/main/resources/protos/Input.proto b/suripu-api/src/main/resources/protos/Input.proto index 5c420a072..862cff64d 100644 --- a/suripu-api/src/main/resources/protos/Input.proto +++ b/suripu-api/src/main/resources/protos/Input.proto @@ -228,20 +228,25 @@ message periodic_data { optional int32 dust=5; optional string name=6; optional bytes mac=7; + optional int32 light_variability=8; optional int32 light_tonality=9; + optional int32 firmware_version=10; + optional int32 dust_variability=13; + optional int32 dust_max=14; + optional int32 dust_min=15; + message pill_data { // Be careful when copy paste, the index is not right :) - optional string deviceId = 3; - optional int32 batteryLevel = 9; - optional int32 uptime = 10; - optional int32 motionData = 11; - - optional bytes motionDataEncrypted = 2; optional int32 firmwareVersion = 1; + optional bytes motionDataEncrypted = 2; + optional string deviceId = 3; + optional int32 batteryLevel = 4; + optional int32 uptime = 5; + optional int32 motionData = 6; } repeated pill_data pills=11; optional string device_id = 12; -} +} \ No newline at end of file From 7a157db3bb65bd4e5d753cada8a5c196c99bacc9 Mon Sep 17 00:00:00 2001 From: kingshy Date: Wed, 22 Oct 2014 15:29:16 -0700 Subject: [PATCH 5/6] add additional dust stats: variance, min and max --- sql/sensors/device_sensors/create.sql | 12 +- .../src/main/resources/protos/Input_pb2.py | 129 +++++++++++------- .../hello/suripu/core/db/DeviceDataDAO.java | 14 +- .../core/db/binders/BindDeviceData.java | 4 +- .../db/mappers/DeviceDataBucketMapper.java | 3 + .../core/db/mappers/DeviceDataMapper.java | 3 + .../hello/suripu/core/models/DeviceData.java | 40 +++++- .../hello/suripu/core/db/BucketingTest.java | 4 +- .../suripu/core/models/DeviceDataTest.java | 3 + .../service/resources/ReceiveResource.java | 9 ++ 10 files changed, 165 insertions(+), 56 deletions(-) diff --git a/sql/sensors/device_sensors/create.sql b/sql/sensors/device_sensors/create.sql index 4726ffca6..cc292a099 100644 --- a/sql/sensors/device_sensors/create.sql +++ b/sql/sensors/device_sensors/create.sql @@ -54,6 +54,10 @@ CREATE TABLE device_sensors_master ( ambient_light_peakiness INTEGER, ambient_humidity INTEGER, ambient_air_quality INTEGER, + ambient_air_quality_raw INTEGER, -- raw counts + ambient_dust_variance INTEGER, -- raw counts + ambient_dust_min INTEGER, -- raw counts + ambient_dust_max INTEGER, -- raw counts ts TIMESTAMP, local_utc_ts TIMESTAMP, offset_millis INTEGER @@ -71,7 +75,6 @@ CREATE UNIQUE INDEX uniq_device_id_account_id_ts_on_par_default on device_sensor -- add new columns for additional light values (10/16/2014) ALTER TABLE device_sensors_master ADD COLUMN ambient_light_variance INTEGER DEFAULT 0; ALTER TABLE device_sensors_master ADD COLUMN ambient_light_peakiness INTEGER DEFAULT 0; -ALTER TABLE device_sensors_master ADD COLUMN ambient_air_quality_raw INTEGER DEFAULT 0; -- save raw counts -- store int instead of float (10/16/2014) ALTER TABLE device_sensors_master ALTER COLUMN ambient_temp SET DATA TYPE INTEGER; @@ -79,6 +82,13 @@ ALTER TABLE device_sensors_master ALTER COLUMN ambient_light SET DATA TYPE INTEG ALTER TABLE device_sensors_master ALTER COLUMN ambient_humidity SET DATA TYPE INTEGER; ALTER TABLE device_sensors_master ALTER COLUMN ambient_air_quality SET DATA TYPE INTEGER; +-- additional dust stats (10/22/2014) +ALTER TABLE device_sensors_master ADD COLUMN ambient_air_quality_raw INTEGER DEFAULT 0; -- save raw counts +ALTER TABLE device_sensors_master ADD COLUMN ambient_dust_variance INTEGER DEFAULT 0; +ALTER TABLE device_sensors_master ADD COLUMN ambient_dust_min INTEGER DEFAULT 0; +ALTER TABLE device_sensors_master ADD COLUMN ambient_dust_max INTEGER DEFAULT 0; + + -- Trigger function for master insert CREATE OR REPLACE FUNCTION device_sensors_master_insert_function() RETURNS TRIGGER LANGUAGE plpgsql AS $BODY$ diff --git a/suripu-api/src/main/resources/protos/Input_pb2.py b/suripu-api/src/main/resources/protos/Input_pb2.py index f793443e1..d66a993cc 100644 --- a/suripu-api/src/main/resources/protos/Input_pb2.py +++ b/suripu-api/src/main/resources/protos/Input_pb2.py @@ -13,7 +13,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( name='Input.proto', package='hello', - serialized_pb='\n\x0bInput.proto\x12\x05hello\"\x8f\x03\n\x11SensorSampleBatch\x12\x36\n\x07samples\x18\x01 \x03(\x0b\x32%.hello.SensorSampleBatch.SensorSample\x12\x11\n\tdevice_id\x18\x02 \x01(\t\x1a\xae\x02\n\x0cSensorSample\x12\x45\n\x0bsensor_type\x18\x01 \x01(\x0e\x32\x30.hello.SensorSampleBatch.SensorSample.SensorType\x12\x11\n\ttimestamp\x18\x02 \x01(\x05\x12\r\n\x05value\x18\x03 \x01(\x0c\"\xb4\x01\n\nSensorType\x12\x17\n\x13\x41MBIENT_TEMPERATURE\x10\x00\x12\x14\n\x10\x41MBIENT_HUMIDITY\x10\x01\x12\x11\n\rAMBIENT_LIGHT\x10\x02\x12\x14\n\x10\x41MBIENT_DECIBELS\x10\x03\x12\x17\n\x13\x41MBIENT_AIR_QUALITY\x10\x04\x12\x07\n\x03GPS\x10\x05\x12\x16\n\x12PHONE_ACCELERATION\x10\x06\x12\x14\n\x10PHONE_STEP_COUNT\x10\x07\"\xd5\x01\n\x11MotionSensorBatch\x12;\n\x0cmanufacturer\x18\x01 \x01(\x0e\x32%.hello.MotionSensorBatch.Manufacturer\x12\x36\n\x07samples\x18\x02 \x03(\x0b\x32%.hello.MotionSensorBatch.MotionSensor\x1a\x30\n\x0cMotionSensor\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\x12\r\n\x05value\x18\x02 \x01(\x05\"\x19\n\x0cManufacturer\x12\t\n\x05HELLO\x10\x00\"\xad\x01\n\x10TrackerDataBatch\x12\x34\n\x07samples\x18\x01 \x03(\x0b\x32#.hello.TrackerDataBatch.TrackerData\x1a\x63\n\x0bTrackerData\x12\x12\n\ntracker_id\x18\x01 \x01(\t\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\x12\x15\n\roffset_millis\x18\x03 \x01(\x05\x12\x16\n\x0esvm_no_gravity\x18\x04 \x01(\x05\"\x89\x04\n\x11SimpleSensorBatch\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12<\n\x07samples\x18\x02 \x03(\x0b\x32+.hello.SimpleSensorBatch.SimpleSensorSample\x1a\x61\n\x07GpsInfo\x12\x10\n\x08latitude\x18\x01 \x01(\x02\x12\x11\n\tlongitude\x18\x02 \x01(\x02\x12\x10\n\x08\x61\x63\x63uracy\x18\x03 \x01(\x02\x12\r\n\x05speed\x18\x04 \x01(\x02\x12\x10\n\x08provider\x18\x05 \x01(\t\x1a\xbf\x02\n\x12SimpleSensorSample\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\x12\x1b\n\x13\x61mbient_temperature\x18\x02 \x01(\x02\x12\x18\n\x10\x61mbient_humidity\x18\x03 \x01(\x02\x12\x15\n\rambient_light\x18\x04 \x01(\x02\x12\x18\n\x10\x61mbient_decibels\x18\x05 \x01(\x02\x12\x1b\n\x13\x61mbient_air_quality\x18\x06 \x01(\x02\x12\x13\n\x0b\x64\x65vice_data\x18\x07 \x01(\x0c\x12\x1d\n\x15\x64\x65vice_data_signature\x18\x08 \x01(\x0c\x12\x17\n\x0fsound_amplitude\x18\t \x01(\x02\x12-\n\x03gps\x18\n \x01(\x0b\x32 .hello.SimpleSensorBatch.GpsInfo\x12\x15\n\roffset_millis\x18\x0b \x01(\x05\"z\n\x11\x41\x63tivationRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x12\n\naccount_id\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\x03\x12\x18\n\x10\x66irmware_version\x18\x04 \x01(\t\x12\x11\n\tsignature\x18\x05 \x01(\x0c\"%\n\x12\x41\x63tivationResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\"`\n\x0bSyncRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x18\n\x10\x66irmware_version\x18\x02 \x01(\t\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\x11\n\tsomething\x18\x04 \x01(\t\"\xfb\x07\n\x0cSyncResponse\x12\x14\n\x0cupload_cycle\x18\x01 \x01(\x05\x12\x12\n\nsync_cycle\x18\x02 \x01(\x05\x12\x15\n\racc_scan_cyle\x18\x03 \x01(\x05\x12\x1d\n\x15\x61\x63\x63_sampling_interval\x18\x04 \x01(\x05\x12 \n\x18\x64\x65vice_sampling_interval\x18\x05 \x01(\x05\x12(\n\x05\x61larm\x18\x06 \x01(\x0b\x32\x19.hello.SyncResponse.Alarm\x12\x39\n\x0epairing_action\x18\x07 \x01(\x0b\x32!.hello.SyncResponse.PairingAction\x12\x33\n\x0bwhite_noise\x18\x08 \x01(\x0b\x32\x1e.hello.SyncResponse.WhiteNoise\x12\x35\n\x0c\x66lash_action\x18\t \x01(\x0b\x32\x1f.hello.SyncResponse.FlashAction\x1a_\n\x05\x41larm\x12\x12\n\nstart_time\x18\x01 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x02 \x01(\x05\x12\x16\n\x0bringtone_id\x18\x03 \x01(\x05:\x01\x31\x12\x18\n\x0cringtone_ids\x18\x04 \x03(\x03\x42\x02\x10\x01\x1a}\n\rPairingAction\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12:\n\x04type\x18\x02 \x01(\x0e\x32,.hello.SyncResponse.PairingAction.ActionType\"\"\n\nActionType\x12\x08\n\x04PAIR\x10\x00\x12\n\n\x06UNPAIR\x10\x01\x1a\x44\n\nWhiteNoise\x12\x12\n\nstart_time\x18\x01 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x02 \x01(\x05\x12\x10\n\x08sound_id\x18\x03 \x01(\x05\x1a\xf1\x02\n\x0b\x46lashAction\x12\x38\n\x05led_1\x18\x01 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_2\x18\x02 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_3\x18\x03 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_4\x18\x04 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_5\x18\x05 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x1a@\n\tLEDAction\x12\r\n\x05\x63olor\x18\x01 \x01(\x05\x12\x12\n\nstart_time\x18\x02 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x03 \x01(\x05\"=\n\x08PillData\x12\x0f\n\x07pill_id\x18\x01 \x01(\t\x12\x12\n\naccount_id\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\xef\x01\n\x0fPillDataKinesis\x12\x0f\n\x07pill_id\x18\x01 \x01(\t\x12\x12\n\naccount_id\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\x03\x12\r\n\x05value\x18\x04 \x01(\x03\x12\x14\n\x0coffsetMillis\x18\x05 \x01(\x05\x12\x15\n\rencryptedData\x18\x06 \x01(\x0c\x12\x14\n\x0c\x62\x61tteryLevel\x18\x07 \x01(\x05\x12\x17\n\x0f\x66irmwareVersion\x18\x08 \x01(\x05\x12\x12\n\npillIdLong\x18\t \x01(\x03\x12\x15\n\raccountIdLong\x18\n \x01(\x03\x12\x0e\n\x06upTime\x18\x0b \x01(\x05\"\xd4\x01\n\x0ePillBlobHeader\x12\x1d\n\x15\x66irst_sequence_number\x18\x01 \x01(\t\x12\x1c\n\x14last_sequence_number\x18\x02 \x01(\t\x12\x19\n\x11\x66irst_sample_date\x18\x03 \x01(\t\x12\x18\n\x10last_sample_date\x18\x04 \x01(\t\x12%\n\x1d\x63ompressed_bitmap_account_ids\x18\x05 \x01(\x0c\x12\x16\n\x0e\x64\x61ta_file_name\x18\x06 \x01(\t\x12\x11\n\tnum_items\x18\x07 \x01(\x05\"*\n\x08PillBlob\x12\x1e\n\x05items\x18\x01 \x03(\x0b\x32\x0f.hello.PillData\"\x8c\x01\n\nEventBatch\x12+\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x1b.hello.EventBatch.EventItem\x1aQ\n\tEventItem\x12\x17\n\x0fstart_timestamp\x18\x01 \x01(\x03\x12\x15\n\rend_timestamp\x18\x02 \x01(\x03\x12\x14\n\x0coffsetMillis\x18\x03 \x01(\x05\"\x8d\x03\n\rperiodic_data\x12\x11\n\tunix_time\x18\x01 \x01(\x05\x12\r\n\x05light\x18\x02 \x01(\x05\x12\x13\n\x0btemperature\x18\x03 \x01(\x05\x12\x10\n\x08humidity\x18\x04 \x01(\x05\x12\x0c\n\x04\x64ust\x18\x05 \x01(\x05\x12\x0c\n\x04name\x18\x06 \x01(\t\x12\x0b\n\x03mac\x18\x07 \x01(\x0c\x12\x19\n\x11light_variability\x18\x08 \x01(\x05\x12\x16\n\x0elight_tonality\x18\t \x01(\x05\x12\x18\n\x10\x66irmware_version\x18\n \x01(\x05\x12-\n\x05pills\x18\x0b \x03(\x0b\x32\x1e.hello.periodic_data.pill_data\x1a\x8d\x01\n\tpill_data\x12\x10\n\x08\x64\x65viceId\x18\x03 \x01(\t\x12\x14\n\x0c\x62\x61tteryLevel\x18\t \x01(\x05\x12\x0e\n\x06uptime\x18\n \x01(\x05\x12\x12\n\nmotionData\x18\x0b \x01(\x05\x12\x1b\n\x13motionDataEncrypted\x18\x02 \x01(\x0c\x12\x17\n\x0f\x66irmwareVersion\x18\x01 \x01(\x05\x42)\n\x1a\x63om.hello.suripu.api.inputB\x0bInputProtos') + serialized_pb='\n\x0bInput.proto\x12\x05hello\"\x8f\x03\n\x11SensorSampleBatch\x12\x36\n\x07samples\x18\x01 \x03(\x0b\x32%.hello.SensorSampleBatch.SensorSample\x12\x11\n\tdevice_id\x18\x02 \x01(\t\x1a\xae\x02\n\x0cSensorSample\x12\x45\n\x0bsensor_type\x18\x01 \x01(\x0e\x32\x30.hello.SensorSampleBatch.SensorSample.SensorType\x12\x11\n\ttimestamp\x18\x02 \x01(\x05\x12\r\n\x05value\x18\x03 \x01(\x0c\"\xb4\x01\n\nSensorType\x12\x17\n\x13\x41MBIENT_TEMPERATURE\x10\x00\x12\x14\n\x10\x41MBIENT_HUMIDITY\x10\x01\x12\x11\n\rAMBIENT_LIGHT\x10\x02\x12\x14\n\x10\x41MBIENT_DECIBELS\x10\x03\x12\x17\n\x13\x41MBIENT_AIR_QUALITY\x10\x04\x12\x07\n\x03GPS\x10\x05\x12\x16\n\x12PHONE_ACCELERATION\x10\x06\x12\x14\n\x10PHONE_STEP_COUNT\x10\x07\"\xd5\x01\n\x11MotionSensorBatch\x12;\n\x0cmanufacturer\x18\x01 \x01(\x0e\x32%.hello.MotionSensorBatch.Manufacturer\x12\x36\n\x07samples\x18\x02 \x03(\x0b\x32%.hello.MotionSensorBatch.MotionSensor\x1a\x30\n\x0cMotionSensor\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\x12\r\n\x05value\x18\x02 \x01(\x05\"\x19\n\x0cManufacturer\x12\t\n\x05HELLO\x10\x00\"\xad\x01\n\x10TrackerDataBatch\x12\x34\n\x07samples\x18\x01 \x03(\x0b\x32#.hello.TrackerDataBatch.TrackerData\x1a\x63\n\x0bTrackerData\x12\x12\n\ntracker_id\x18\x01 \x01(\t\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\x12\x15\n\roffset_millis\x18\x03 \x01(\x05\x12\x16\n\x0esvm_no_gravity\x18\x04 \x01(\x05\"\x89\x04\n\x11SimpleSensorBatch\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12<\n\x07samples\x18\x02 \x03(\x0b\x32+.hello.SimpleSensorBatch.SimpleSensorSample\x1a\x61\n\x07GpsInfo\x12\x10\n\x08latitude\x18\x01 \x01(\x02\x12\x11\n\tlongitude\x18\x02 \x01(\x02\x12\x10\n\x08\x61\x63\x63uracy\x18\x03 \x01(\x02\x12\r\n\x05speed\x18\x04 \x01(\x02\x12\x10\n\x08provider\x18\x05 \x01(\t\x1a\xbf\x02\n\x12SimpleSensorSample\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\x12\x1b\n\x13\x61mbient_temperature\x18\x02 \x01(\x02\x12\x18\n\x10\x61mbient_humidity\x18\x03 \x01(\x02\x12\x15\n\rambient_light\x18\x04 \x01(\x02\x12\x18\n\x10\x61mbient_decibels\x18\x05 \x01(\x02\x12\x1b\n\x13\x61mbient_air_quality\x18\x06 \x01(\x02\x12\x13\n\x0b\x64\x65vice_data\x18\x07 \x01(\x0c\x12\x1d\n\x15\x64\x65vice_data_signature\x18\x08 \x01(\x0c\x12\x17\n\x0fsound_amplitude\x18\t \x01(\x02\x12-\n\x03gps\x18\n \x01(\x0b\x32 .hello.SimpleSensorBatch.GpsInfo\x12\x15\n\roffset_millis\x18\x0b \x01(\x05\"z\n\x11\x41\x63tivationRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x12\n\naccount_id\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\x03\x12\x18\n\x10\x66irmware_version\x18\x04 \x01(\t\x12\x11\n\tsignature\x18\x05 \x01(\x0c\"%\n\x12\x41\x63tivationResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\"`\n\x0bSyncRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x18\n\x10\x66irmware_version\x18\x02 \x01(\t\x12\x11\n\tsignature\x18\x03 \x01(\x0c\x12\x11\n\tsomething\x18\x04 \x01(\t\"\x91\x08\n\x0cSyncResponse\x12\x14\n\x0cupload_cycle\x18\x01 \x01(\x05\x12\x12\n\nsync_cycle\x18\x02 \x01(\x05\x12\x15\n\racc_scan_cyle\x18\x03 \x01(\x05\x12\x1d\n\x15\x61\x63\x63_sampling_interval\x18\x04 \x01(\x05\x12 \n\x18\x64\x65vice_sampling_interval\x18\x05 \x01(\x05\x12(\n\x05\x61larm\x18\x06 \x01(\x0b\x32\x19.hello.SyncResponse.Alarm\x12\x39\n\x0epairing_action\x18\x07 \x01(\x0b\x32!.hello.SyncResponse.PairingAction\x12\x33\n\x0bwhite_noise\x18\x08 \x01(\x0b\x32\x1e.hello.SyncResponse.WhiteNoise\x12\x35\n\x0c\x66lash_action\x18\t \x01(\x0b\x32\x1f.hello.SyncResponse.FlashAction\x12\x14\n\x0creset_device\x18\n \x01(\x08\x1a_\n\x05\x41larm\x12\x12\n\nstart_time\x18\x01 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x02 \x01(\x05\x12\x16\n\x0bringtone_id\x18\x03 \x01(\x05:\x01\x31\x12\x18\n\x0cringtone_ids\x18\x04 \x03(\x03\x42\x02\x10\x01\x1a}\n\rPairingAction\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12:\n\x04type\x18\x02 \x01(\x0e\x32,.hello.SyncResponse.PairingAction.ActionType\"\"\n\nActionType\x12\x08\n\x04PAIR\x10\x00\x12\n\n\x06UNPAIR\x10\x01\x1a\x44\n\nWhiteNoise\x12\x12\n\nstart_time\x18\x01 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x02 \x01(\x05\x12\x10\n\x08sound_id\x18\x03 \x01(\x05\x1a\xf1\x02\n\x0b\x46lashAction\x12\x38\n\x05led_1\x18\x01 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_2\x18\x02 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_3\x18\x03 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_4\x18\x04 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x12\x38\n\x05led_5\x18\x05 \x01(\x0b\x32).hello.SyncResponse.FlashAction.LEDAction\x1a@\n\tLEDAction\x12\r\n\x05\x63olor\x18\x01 \x01(\x05\x12\x12\n\nstart_time\x18\x02 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x03 \x01(\x05\"=\n\x08PillData\x12\x0f\n\x07pill_id\x18\x01 \x01(\t\x12\x12\n\naccount_id\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\xef\x01\n\x0fPillDataKinesis\x12\x0f\n\x07pill_id\x18\x01 \x01(\t\x12\x12\n\naccount_id\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\x03\x12\r\n\x05value\x18\x04 \x01(\x03\x12\x14\n\x0coffsetMillis\x18\x05 \x01(\x05\x12\x15\n\rencryptedData\x18\x06 \x01(\x0c\x12\x14\n\x0c\x62\x61tteryLevel\x18\x07 \x01(\x05\x12\x17\n\x0f\x66irmwareVersion\x18\x08 \x01(\x05\x12\x12\n\npillIdLong\x18\t \x01(\x03\x12\x15\n\raccountIdLong\x18\n \x01(\x03\x12\x0e\n\x06upTime\x18\x0b \x01(\x05\"\xd4\x01\n\x0ePillBlobHeader\x12\x1d\n\x15\x66irst_sequence_number\x18\x01 \x01(\t\x12\x1c\n\x14last_sequence_number\x18\x02 \x01(\t\x12\x19\n\x11\x66irst_sample_date\x18\x03 \x01(\t\x12\x18\n\x10last_sample_date\x18\x04 \x01(\t\x12%\n\x1d\x63ompressed_bitmap_account_ids\x18\x05 \x01(\x0c\x12\x16\n\x0e\x64\x61ta_file_name\x18\x06 \x01(\t\x12\x11\n\tnum_items\x18\x07 \x01(\x05\"*\n\x08PillBlob\x12\x1e\n\x05items\x18\x01 \x03(\x0b\x32\x0f.hello.PillData\"\x8c\x01\n\nEventBatch\x12+\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x1b.hello.EventBatch.EventItem\x1aQ\n\tEventItem\x12\x17\n\x0fstart_timestamp\x18\x01 \x01(\x03\x12\x15\n\rend_timestamp\x18\x02 \x01(\x03\x12\x14\n\x0coffsetMillis\x18\x03 \x01(\x05\"\xde\x03\n\rperiodic_data\x12\x11\n\tunix_time\x18\x01 \x01(\x05\x12\r\n\x05light\x18\x02 \x01(\x05\x12\x13\n\x0btemperature\x18\x03 \x01(\x05\x12\x10\n\x08humidity\x18\x04 \x01(\x05\x12\x0c\n\x04\x64ust\x18\x05 \x01(\x05\x12\x0c\n\x04name\x18\x06 \x01(\t\x12\x0b\n\x03mac\x18\x07 \x01(\x0c\x12\x19\n\x11light_variability\x18\x08 \x01(\x05\x12\x16\n\x0elight_tonality\x18\t \x01(\x05\x12\x18\n\x10\x66irmware_version\x18\n \x01(\x05\x12\x18\n\x10\x64ust_variability\x18\r \x01(\x05\x12\x10\n\x08\x64ust_max\x18\x0e \x01(\x05\x12\x10\n\x08\x64ust_min\x18\x0f \x01(\x05\x12-\n\x05pills\x18\x0b \x03(\x0b\x32\x1e.hello.periodic_data.pill_data\x12\x11\n\tdevice_id\x18\x0c \x01(\t\x1a\x8d\x01\n\tpill_data\x12\x17\n\x0f\x66irmwareVersion\x18\x01 \x01(\x05\x12\x1b\n\x13motionDataEncrypted\x18\x02 \x01(\x0c\x12\x10\n\x08\x64\x65viceId\x18\x03 \x01(\t\x12\x14\n\x0c\x62\x61tteryLevel\x18\x04 \x01(\x05\x12\x0e\n\x06uptime\x18\x05 \x01(\x05\x12\x12\n\nmotionData\x18\x06 \x01(\x05\x42)\n\x1a\x63om.hello.suripu.api.inputB\x0bInputProtos') @@ -96,8 +96,8 @@ ], containing_type=None, options=None, - serialized_start=2145, - serialized_end=2179, + serialized_start=2167, + serialized_end=2201, ) @@ -688,8 +688,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=1957, - serialized_end=2052, + serialized_start=1979, + serialized_end=2074, ) _SYNCRESPONSE_PAIRINGACTION = _descriptor.Descriptor( @@ -723,8 +723,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=2054, - serialized_end=2179, + serialized_start=2076, + serialized_end=2201, ) _SYNCRESPONSE_WHITENOISE = _descriptor.Descriptor( @@ -764,8 +764,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=2181, - serialized_end=2249, + serialized_start=2203, + serialized_end=2271, ) _SYNCRESPONSE_FLASHACTION_LEDACTION = _descriptor.Descriptor( @@ -805,8 +805,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=2557, - serialized_end=2621, + serialized_start=2579, + serialized_end=2643, ) _SYNCRESPONSE_FLASHACTION = _descriptor.Descriptor( @@ -860,8 +860,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=2252, - serialized_end=2621, + serialized_start=2274, + serialized_end=2643, ) _SYNCRESPONSE = _descriptor.Descriptor( @@ -934,6 +934,13 @@ message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), + _descriptor.FieldDescriptor( + name='reset_device', full_name='hello.SyncResponse.reset_device', index=9, + number=10, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), ], extensions=[ ], @@ -944,7 +951,7 @@ is_extendable=False, extension_ranges=[], serialized_start=1602, - serialized_end=2621, + serialized_end=2643, ) @@ -985,8 +992,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=2623, - serialized_end=2684, + serialized_start=2645, + serialized_end=2706, ) @@ -1083,8 +1090,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=2687, - serialized_end=2926, + serialized_start=2709, + serialized_end=2948, ) @@ -1153,8 +1160,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=2929, - serialized_end=3141, + serialized_start=2951, + serialized_end=3163, ) @@ -1181,8 +1188,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=3143, - serialized_end=3185, + serialized_start=3165, + serialized_end=3207, ) @@ -1223,8 +1230,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=3247, - serialized_end=3328, + serialized_start=3269, + serialized_end=3350, ) _EVENTBATCH = _descriptor.Descriptor( @@ -1250,8 +1257,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=3188, - serialized_end=3328, + serialized_start=3210, + serialized_end=3350, ) @@ -1263,43 +1270,43 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='deviceId', full_name='hello.periodic_data.pill_data.deviceId', index=0, - number=3, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=unicode("", "utf-8"), + name='firmwareVersion', full_name='hello.periodic_data.pill_data.firmwareVersion', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='batteryLevel', full_name='hello.periodic_data.pill_data.batteryLevel', index=1, - number=9, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, + name='motionDataEncrypted', full_name='hello.periodic_data.pill_data.motionDataEncrypted', index=1, + number=2, type=12, cpp_type=9, label=1, + has_default_value=False, default_value="", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='uptime', full_name='hello.periodic_data.pill_data.uptime', index=2, - number=10, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, + name='deviceId', full_name='hello.periodic_data.pill_data.deviceId', index=2, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=unicode("", "utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='motionData', full_name='hello.periodic_data.pill_data.motionData', index=3, - number=11, type=5, cpp_type=1, label=1, + name='batteryLevel', full_name='hello.periodic_data.pill_data.batteryLevel', index=3, + number=4, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='motionDataEncrypted', full_name='hello.periodic_data.pill_data.motionDataEncrypted', index=4, - number=2, type=12, cpp_type=9, label=1, - has_default_value=False, default_value="", + name='uptime', full_name='hello.periodic_data.pill_data.uptime', index=4, + number=5, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='firmwareVersion', full_name='hello.periodic_data.pill_data.firmwareVersion', index=5, - number=1, type=5, cpp_type=1, label=1, + name='motionData', full_name='hello.periodic_data.pill_data.motionData', index=5, + number=6, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, @@ -1313,8 +1320,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=3587, - serialized_end=3728, + serialized_start=3690, + serialized_end=3831, ) _PERIODIC_DATA = _descriptor.Descriptor( @@ -1395,12 +1402,40 @@ is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='pills', full_name='hello.periodic_data.pills', index=10, + name='dust_variability', full_name='hello.periodic_data.dust_variability', index=10, + number=13, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='dust_max', full_name='hello.periodic_data.dust_max', index=11, + number=14, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='dust_min', full_name='hello.periodic_data.dust_min', index=12, + number=15, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='pills', full_name='hello.periodic_data.pills', index=13, number=11, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), + _descriptor.FieldDescriptor( + name='device_id', full_name='hello.periodic_data.device_id', index=14, + number=12, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=unicode("", "utf-8"), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), ], extensions=[ ], @@ -1410,8 +1445,8 @@ options=None, is_extendable=False, extension_ranges=[], - serialized_start=3331, - serialized_end=3728, + serialized_start=3353, + serialized_end=3831, ) _SENSORSAMPLEBATCH_SENSORSAMPLE.fields_by_name['sensor_type'].enum_type = _SENSORSAMPLEBATCH_SENSORSAMPLE_SENSORTYPE diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java b/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java index d6567f9b3..13cb7de3b 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/DeviceDataDAO.java @@ -30,11 +30,11 @@ public abstract class DeviceDataDAO { private static final Logger LOGGER = LoggerFactory.getLogger(DeviceDataDAO.class); @SqlUpdate("INSERT INTO device_sensors_master (account_id, device_id, ts, local_utc_ts, offset_millis, " + - "ambient_temp, ambient_light, ambient_light_variance, ambient_light_peakiness, " + - "ambient_humidity, ambient_air_quality, ambient_air_quality_raw) VALUES " + + "ambient_temp, ambient_light, ambient_light_variance, ambient_light_peakiness, ambient_humidity, " + + "ambient_air_quality, ambient_air_quality_raw, ambient_dust_variance, ambient_dust_min, ambient_dust_max) VALUES " + "(:account_id, :device_id, :ts, :local_utc_ts, :offset_millis, " + - ":ambient_temp, :ambient_light, :ambient_light_variance, :ambient_light_peakiness, " + - ":ambient_humidity, :ambient_air_quality, :ambient_air_quality_raw)") + ":ambient_temp, :ambient_light, :ambient_light_variance, :ambient_light_peakiness, :ambient_humidity, " + + ":ambient_air_quality, :ambient_air_quality_raw, :ambient_dust_variance, :ambient_dust_min, :ambient_dust_max)") public abstract void insert(@BindDeviceData final DeviceData deviceData); @RegisterMapper(DeviceDataMapper.class) @@ -65,6 +65,9 @@ public abstract ImmutableList getBetweenByLocalTime( "ROUND(AVG(ambient_humidity)) as ambient_humidity," + "ROUND(AVG(ambient_air_quality)) as ambient_air_quality," + "ROUND(AVG(ambient_air_quality_raw)) as ambient_air_quality_raw," + + "ROUND(AVG(ambient_dust_variance)) as ambient_dust_variance," + + "ROUND(AVG(ambient_dust_min)) as ambient_dust_min," + + "ROUND(AVG(ambient_dust_max)) as ambient_dust_max," + "ROUND(MIN(offset_millis)) as offset_millis," + "date_trunc('hour', ts) + (CAST(date_part('minute', ts) AS integer) / :slot_duration) * :slot_duration * interval '1 min' AS ts_bucket " + "FROM device_sensors_master " + @@ -168,6 +171,9 @@ public List generateTimeSerie( "AVG(ambient_humidity) as ambient_humidity, " + "AVG(ambient_air_quality) as ambient_air_quality, " + "AVG(ambient_air_quality_raw) as ambient_air_quality_raw, " + + "AVG(ambient_dust_variance) as ambient_dust_variance, " + + "AVG(ambient_dust_min) as ambient_dust_min, " + + "AVG(ambient_dust_max) as ambient_dust_max, " + "AVG(ambient_light) as ambient_light," + "AVG(ambient_light_variance) as ambient_light_variance," + "AVG(ambient_light_peakiness) as ambient_light_peakiness," + diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java b/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java index 05e25b9c4..f8be958c5 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/binders/BindDeviceData.java @@ -33,7 +33,9 @@ public void bind(final SQLStatement q, final BindDeviceData bind, final DeviceDa q.bind("ambient_humidity", model.ambientHumidity); q.bind("ambient_air_quality", model.ambientAirQuality); q.bind("ambient_air_quality_raw", model.ambientAirQualityRaw); - + q.bind("ambient_dust_variance", model.ambientDustVariance); + q.bind("ambient_dust_min", model.ambientDustMin); + q.bind("ambient_dust_max", model.ambientDustMax); q.bind("ts", model.dateTimeUTC); q.bind("local_utc_ts", model.dateTimeUTC.plusMillis(model.offsetMillis)); q.bind("offset_millis", model.offsetMillis); diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java index 1074940fe..c652d18d8 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataBucketMapper.java @@ -19,6 +19,9 @@ public DeviceData map(int index, ResultSet r, StatementContext ctx) throws SQLEx r.getInt("ambient_humidity"), r.getInt("ambient_air_quality"), r.getInt("ambient_air_quality_raw"), + r.getInt("ambient_dust_variance"), + r.getInt("ambient_dust_min"), + r.getInt("ambient_dust_max"), r.getInt("ambient_light"), r.getInt("ambient_light_variance"), r.getInt("ambient_light_peakiness"), diff --git a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java index 54c1de8d9..a475142ba 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/db/mappers/DeviceDataMapper.java @@ -19,6 +19,9 @@ public DeviceData map(int index, ResultSet r, StatementContext ctx) throws SQLEx r.getInt("ambient_humidity"), r.getInt("ambient_air_quality"), r.getInt("ambient_air_quality_raw"), + r.getInt("ambient_dust_variance"), + r.getInt("ambient_dust_min"), + r.getInt("ambient_dust_max"), r.getInt("ambient_light"), r.getInt("ambient_light_variance"), r.getInt("ambient_light_peakiness"), diff --git a/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java b/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java index 596d68637..6a35e35c4 100644 --- a/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java +++ b/suripu-core/src/main/java/com/hello/suripu/core/models/DeviceData.java @@ -31,6 +31,15 @@ public class DeviceData { @JsonProperty("ambient_air_quality_raw") public final int ambientAirQualityRaw; + @JsonProperty("ambient_dust_variance") + public final int ambientDustVariance; + + @JsonProperty("ambient_dust_min") + public final int ambientDustMin; + + @JsonProperty("ambient_dust_max") + public final int ambientDustMax; + @JsonProperty("ambient_light") public final int ambientLight; @@ -53,6 +62,9 @@ public DeviceData( final int ambientHumidity, final int ambientAirQuality, final int ambientAirQualityRaw, + final int ambientDustVariance, + final int ambientDustMin, + final int ambientDustMax, final int ambientLight, final int ambientLightVariance, final int ambientLightPeakiness, @@ -64,6 +76,9 @@ public DeviceData( this.ambientHumidity = ambientHumidity; this.ambientAirQuality = ambientAirQuality; this.ambientAirQualityRaw = ambientAirQualityRaw; + this.ambientDustVariance = ambientDustVariance; + this.ambientDustMin = ambientDustMin; + this.ambientDustMax = ambientDustMax; this.ambientLight = ambientLight; this.dateTimeUTC = dateTimeUTC; this.ambientLightVariance = ambientLightVariance; @@ -110,6 +125,9 @@ public static class Builder{ private int ambientHumidity; private int ambientAirQuality; private int ambientAirQualityRaw; + private int ambientDustVariance; + private int ambientDustMin; + private int ambientDustMax; private int ambientLight; private int ambientLightVariance; private int ambientLightPeakiness; @@ -146,6 +164,21 @@ public Builder withAmbientAirQualityRaw(final int ambientAirQuality) { return this; } + public Builder withAmbientDustVariance(final int ambientDustVariance) { + this.ambientDustVariance= ambientDustVariance; + return this; + } + + public Builder withAmbientDustMin(final int ambientDustMin) { + this.ambientDustMin= ambientDustMin; + return this; + } + + public Builder withAmbientDustMax(final int ambientDustMax) { + this.ambientDustMax = ambientDustMax; + return this; + } + public Builder withAmbientLight(final int ambientLight){ this.ambientLight = ambientLight; return this; @@ -172,7 +205,9 @@ public Builder withOffsetMillis(final Integer offsetMillis){ } public DeviceData build(){ - return new DeviceData(this.accountId, this.deviceId, this.ambientTemperature, this.ambientHumidity, this.ambientAirQuality, this.ambientAirQualityRaw, this.ambientLight, this.ambientLightVariance, this.ambientLightPeakiness, this.dateTimeUTC, this.offsetMillis); + return new DeviceData(this.accountId, this.deviceId, this.ambientTemperature, this.ambientHumidity, + this.ambientAirQuality, this.ambientAirQualityRaw, this.ambientDustVariance, this.ambientDustMin, this.ambientDustMax, + this.ambientLight, this.ambientLightVariance, this.ambientLightPeakiness, this.dateTimeUTC, this.offsetMillis); } @@ -190,6 +225,9 @@ public String toString() { .add("ambient_light_peakiness", ambientLightPeakiness) .add("ambient_air_quality", ambientAirQuality) .add("ambient_air_quality_raw", ambientAirQualityRaw) + .add("ambient_dust_variance", ambientDustVariance) + .add("ambient_dust_min", ambientDustMin) + .add("ambient_dust_max", ambientDustMax) .add("dateTimeUTC", dateTimeUTC) .add("offset_millis", offsetMillis) .toString(); diff --git a/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java b/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java index a68bbf137..9e55cee7e 100644 --- a/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java +++ b/suripu-core/src/test/java/com/hello/suripu/core/db/BucketingTest.java @@ -29,7 +29,7 @@ public class BucketingTest { private Map generateMap(final DateTime startDate) { - final DeviceData deviceData = new DeviceData(999L, 111L, 222,333,444,555, 666, 777, 888, startDate, 0); + final DeviceData deviceData = new DeviceData(999L, 111L, 222,333,444,555, 0, 0, 0, 666, 777, 888, startDate, 0); final List deviceDataList = new ArrayList<>(); deviceDataList.add(deviceData); @@ -58,7 +58,7 @@ public void testEmptyMap() { public void testPopulateMap() { final Map map = Bucketing.generateEmptyMap(numberOfBuckets, startDate, slotDurationInMinutes); - final DeviceData deviceData = new DeviceData(999L, 111L, 222, 333, 444, 555, 666, 777, 888, startDate, 0); + final DeviceData deviceData = new DeviceData(999L, 111L, 222, 333, 444, 555, 0, 0, 0, 666, 777, 888, startDate, 0); final List deviceDataList = new ArrayList<>(); deviceDataList.add(deviceData); diff --git a/suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java b/suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java index 5b1b2e175..b13f22c67 100644 --- a/suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java +++ b/suripu-core/src/test/java/com/hello/suripu/core/models/DeviceDataTest.java @@ -31,6 +31,9 @@ public void testBuilder() { .withAmbientTemperature(temp) .withAmbientAirQuality(dust, 1) .withAmbientAirQualityRaw(dust) + .withAmbientDustVariance(0) + .withAmbientDustMin(0) + .withAmbientDustMax(100) .withAmbientHumidity(humid) .withAmbientLight(light) .withAmbientLightVariance(14) diff --git a/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java b/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java index d18ffa98b..ea5db2b2a 100644 --- a/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java +++ b/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java @@ -361,6 +361,9 @@ public byte[] morpheusProtobufReceiveEncrypted(final byte[] body) { .withAmbientTemperature(data.getTemperature()) .withAmbientAirQuality(data.getDust(), data.getFirmwareVersion()) .withAmbientAirQualityRaw(data.getDust()) + .withAmbientDustVariance(data.getDustVariability()) + .withAmbientDustMin(data.getDustMin()) + .withAmbientDustMax(data.getDustMax()) .withAmbientHumidity(data.getHumidity()) .withAmbientLight(data.getLight()) .withAmbientLightVariance(data.getLightVariability()) @@ -483,6 +486,9 @@ public String morpheusProtobufReceive(final byte[] body) { .withAmbientTemperature(data.getTemperature()) .withAmbientAirQuality(data.getDust(), data.getFirmwareVersion()) .withAmbientAirQualityRaw(data.getDust()) + .withAmbientDustVariance(0) + .withAmbientDustMin(0) + .withAmbientDustMax(0) .withAmbientHumidity(data.getHumidity()) .withAmbientLight(data.getLight()) .withAmbientLightVariance(data.getLightVariability()) @@ -573,6 +579,9 @@ public Response receiveSimpleData( .withAmbientTemperature(temp) .withAmbientAirQuality(airQuality, 0) .withAmbientAirQualityRaw(airQuality) + .withAmbientDustVariance(0) + .withAmbientDustMin(0) + .withAmbientDustMax(0) .withAmbientHumidity(humidity) .withAmbientLight(light) .withOffsetMillis(offsetMillis) From 3674efd39a870514f02305fdf0f592edb07c9eee Mon Sep 17 00:00:00 2001 From: kingshy Date: Wed, 22 Oct 2014 15:32:14 -0700 Subject: [PATCH 6/6] rm to upper case, dev thing --- .../com/hello/suripu/service/resources/ReceiveResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java b/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java index ea5db2b2a..1acd763bc 100644 --- a/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java +++ b/suripu-service/src/main/java/com/hello/suripu/service/resources/ReceiveResource.java @@ -226,7 +226,7 @@ public byte[] morpheusProtobufReceiveEncrypted(final byte[] body) { } - final String deviceName = deviceIdOptional.get().toUpperCase(); + final String deviceName = deviceIdOptional.get(); LOGGER.debug("Received valid protobuf {}", deviceName.toString()); LOGGER.debug("Received protobuf message {}", TextFormat.shortDebugString(data));