mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-26 17:47:34 +01:00
HuaweiSampleProvider: Improve getRawOrderedActivitySamples
Currently only ActivitySamples that *start* within the specified time frame are loaded from the DB, but ActivitySamples that end in the specified time frame are ignored. On the Dashboard and the activity summary chart some activities might thus be missing. Since the sleep activity usually starts hours before midnight it doesn't get loaded and the Dashboard doesn't properly display the sleep phase. To fix this issue load all ActivitySamples that overlay the specified time frame, that means it also loads samples that end within the timeframe. Fixes issue #4510 Signed-off-by: Patrick Rudolph <rudolphpatrick05@gmail.com>
This commit is contained in:
parent
52d3128474
commit
9830ae20e0
@ -113,6 +113,11 @@ public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivityS
|
||||
return HuaweiActivitySampleDao.Properties.Timestamp;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected Property getOthertimestampSampleProperty() {
|
||||
return HuaweiActivitySampleDao.Properties.OtherTimestamp;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Property getDeviceIdentifierSampleProperty() {
|
||||
@ -248,13 +253,14 @@ public class HuaweiSampleProvider extends AbstractSampleProvider<HuaweiActivityS
|
||||
private List<HuaweiActivitySample> getRawOrderedActivitySamples(int timestampFrom, int timestampTo) {
|
||||
QueryBuilder<HuaweiActivitySample> qb = getSampleDao().queryBuilder();
|
||||
Property timestampProperty = getTimestampSampleProperty();
|
||||
Property otherTimestampProperty = getOthertimestampSampleProperty();
|
||||
Device dbDevice = DBHelper.findDevice(getDevice(), getSession());
|
||||
if (dbDevice == null) {
|
||||
// no device, no samples
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Property deviceProperty = getDeviceIdentifierSampleProperty();
|
||||
qb.where(deviceProperty.eq(dbDevice.getId()), timestampProperty.ge(timestampFrom))
|
||||
qb.where(deviceProperty.eq(dbDevice.getId()), otherTimestampProperty.ge(timestampFrom))
|
||||
.where(timestampProperty.le(timestampTo))
|
||||
.orderAsc(timestampProperty);
|
||||
List<HuaweiActivitySample> samples = qb.build().list();
|
||||
|
Loading…
x
Reference in New Issue
Block a user