treatments : download 24 hours of treatments
This commit is contained in:
parent
85ff093f9e
commit
f9e5d7a7e8
|
@ -13,7 +13,10 @@ enum ConstantsNightScout {
|
|||
/// if the time between the last and last but one reading is less than minimiumTimeBetweenTwoReadingsInMinutes, then the last reading will not be uploaded - except if there's been a disconnect in between these two readings
|
||||
static let minimiumTimeBetweenTwoReadingsInMinutes = 4.75
|
||||
|
||||
/// maximum amount of treatments to sync with Nightscout
|
||||
static let maxTreatmentsToSync = 50
|
||||
/// maximum amount of treatments to upload to NightScout (inclusive updated treatments and treatments marked as deleted)
|
||||
static let maxTreatmentsToUpload = 50
|
||||
|
||||
/// download treatments from nightscout, how manyhours
|
||||
static let maxHoursTreatmentsToDownload = 24.0
|
||||
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public class NightScoutUploadManager: NSObject {
|
|||
|
||||
// get the latest treatments from the last maxTreatmentsDaysToUpload days
|
||||
// this includes treatments in with treatmentDeleted = true
|
||||
let treatmentsToSync = treatmentEntryAccessor.getLatestTreatments(limit: ConstantsNightScout.maxTreatmentsToSync)
|
||||
let treatmentsToSync = treatmentEntryAccessor.getLatestTreatments(limit: ConstantsNightScout.maxTreatmentsToUpload)
|
||||
|
||||
trace("in syncTreatmentsWithNightScout", log: self.oslog, category: ConstantsLog.categoryNightScoutUploadManager, type: .info)
|
||||
|
||||
|
@ -848,7 +848,8 @@ public class NightScoutUploadManager: NSObject {
|
|||
|
||||
trace("in getLatestTreatmentsNSResponses", log: self.oslog, category: ConstantsLog.categoryNightScoutUploadManager, type: .info)
|
||||
|
||||
let queries = [URLQueryItem(name: "count", value: String(ConstantsNightScout.maxTreatmentsToSync))]
|
||||
// query for treatments older than maxHoursTreatmentsToDownload
|
||||
let queries = [URLQueryItem(name: "find[created_at][$gte]", value: String(Date(timeIntervalSinceNow: TimeInterval(hours: -ConstantsNightScout.maxHoursTreatmentsToDownload)).ISOStringFromDate()))]
|
||||
|
||||
getOrDeleteRequest(path: nightScoutTreatmentPath, queries: queries, httpMethod: nil) { (data: Data?, nightScoutResult: NightScoutResult) in
|
||||
|
||||
|
|
Loading…
Reference in New Issue