Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove actualDate as introduced in #22 #55

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FreeAPS/Sources/APS/Storage/CarbsStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class BaseCarbsStorage: CarbsStorage, Injectable {
} else { useDate = useDate.addingTimeInterval(interval.minutes.timeInterval) }

let eachCarbEntry = CarbsEntry(
id: UUID().uuidString, createdAt: entries.last?.createdAt ?? Date(), actualDate: useDate,
id: UUID().uuidString, createdAt: entries.last?.createdAt ?? Date(),
carbs: equivalent, fat: 0, protein: 0, note: nil,
enteredBy: CarbsEntry.manual, isFPU: true,
fpuID: fpuID
Expand Down
2 changes: 0 additions & 2 deletions FreeAPS/Sources/Models/CarbsEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Foundation
struct CarbsEntry: JSON, Equatable, Hashable {
let id: String?
let createdAt: Date
let actualDate: Date?
let carbs: Decimal
let fat: Decimal?
let protein: Decimal?
Expand All @@ -28,7 +27,6 @@ extension CarbsEntry {
private enum CodingKeys: String, CodingKey {
case id = "_id"
case createdAt = "created_at"
case actualDate
case carbs
case fat
case protein
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ extension AddCarbs {
[CarbsEntry(
id: UUID().uuidString,
createdAt: Date.now,
actualDate: date,
carbs: carbs,
fat: fat,
protein: protein,
Expand Down
6 changes: 3 additions & 3 deletions FreeAPS/Sources/Services/HealthKit/HealthKitManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
let sampleDates = samples.map(\.startDate)
let samplesToSave = carbsWithId
.filter { !sampleIDs.contains($0.id ?? "") } // id existing in AH
.filter { !sampleDates.contains($0.actualDate ?? $0.createdAt) } // not id but exactly the same datetime
.filter { !sampleDates.contains($0.createdAt) } // not id but exactly the same datetime
bjornoleh marked this conversation as resolved.
Show resolved Hide resolved
.map {
HKQuantitySample(
type: sampleType,
quantity: HKQuantity(unit: .gram(), doubleValue: Double($0.carbs)),
start: $0.actualDate ?? $0.createdAt,
end: $0.actualDate ?? $0.createdAt,
start: $0.createdAt,
end: $0.createdAt,
metadata: [
HKMetadataKeySyncIdentifier: $0.id ?? "_id",
HKMetadataKeySyncVersion: 1,
Expand Down
1 change: 0 additions & 1 deletion FreeAPS/Sources/Services/WatchManager/WatchManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ extension BaseWatchManager: WCSessionDelegate {
[CarbsEntry(
id: UUID().uuidString,
createdAt: Date.now,
actualDate: Date.now,
carbs: Decimal(carbs),
fat: Decimal(fat),
protein: Decimal(protein), note: nil,
Expand Down