-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: Update CustomLinearCareTaskProgress #15
refactor: Update CustomLinearCareTaskProgress #15
Conversation
…ogressStrategy+Math removed struct CustomLinearCareTaskProgress removed all appearances of CustomLinearCareTaskProgress to LinearCareTaskProgress
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15 +/- ##
========================================
+ Coverage 2.44% 8.30% +5.86%
========================================
Files 35 34 -1
Lines 1352 1313 -39
========================================
+ Hits 33 109 +76
+ Misses 1319 1204 -115 ☔ View full report in Codecov by Sentry. |
Thanks for working on this @luimillan3 can you add test cases for: CareKitEssentials/Tests/CareKitEssentialsTests/OCKOutcomeExtensionsTests.swift Lines 7 to 55 in 094cf72
|
You can use something like the code below to make a dummy event: let scheduleElement = OCKScheduleElement(start: Date(), end: nil, interval: DateComponents(day: 1))
let schedule = OCKSchedule(composing: [scheduleElement])
let task = OCKTask(id: "test", title: nil, carePlanUUID: nil, schedule: schedule)
let value1 = OCKOutcomeValue(2)
let value2 = OCKOutcomeValue(4)
let outcome = OCKOutcome(taskUUID: task.uuid, taskOccurrenceIndex: 0, values: [value1, value2])
guard let scheduleEvent = task.schedule.event(forOccurrenceIndex: 0) else {
XCFail("Should have a schedule event")
return
}
let event = OCKAnyEvent(task: task, outcome: outcome, scheduleEvent: scheduleEvent) Or better, copy this private extension, https://github.com/carekit-apple/CareKit/blob/7416cce107875e58d0dbfd54afb16e007ef79033/CareKit/CareKitTests/Task/TestTaskEvents.swift#L309-L329, to your new test file and add an argument that takes |
Add new test cases for `computeProgressByAveragingOutcomeValues`, `computeProgressByMedianOutcomeValues`, and `computeProgressByStreakOutcomeValues` functions in the `CareTaskProgressStrategy` class. Covers varioues edge cases and increases overall test coverage. feat: add kind parameter to computeProgress functions Add a new `kind` parameter to `computeProgressByAveragingOutcomeValues`, `computeProgressByMedianOutcomeValues`, and `computeProgressByStreakOutcomeValues` functions in the `CareTaskProgressStrategy` class. This allows calculating progress for a specific kind of outcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great so far. I just provided some initial feedback.
Keep up the good work!
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
removes all instances of force unwrapping to prevent potential crashes. style: remove underscores for function, remove unnecessary comments, and formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor style and formatting changes. Also removed all instance of force unwrapping to prevent potential crashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, some nits
Sources/CareKitEssentials/Extensions/CareTaskProgressStrategy+Math.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Added unit test to verify the handling of different kinds the 'computeProgressByAveragingOutcomeValues' function. refacor: simplified value extraction from OCKOutcomeValue Replaced instances of $0.numberValue?.doubleValue with $0.doubleValue to remove unnecessary casting. style: improved readibility by adding new lines
@lmillan1 be sure to use GitHub to re-request me for review (top right of the PR) when this is ready: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, some nits and suggestions
Sources/CareKitEssentials/Extensions/CareTaskProgressStrategy+Math.swift
Outdated
Show resolved
Hide resolved
Sources/CareKitEssentials/Extensions/CareTaskProgressStrategy+Math.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Refactor tests to be able to unwrap optional values using guard statements style: Reduced identation and also tab when needed refactor: Use string variables for kinds to reduce programatic mistakes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits, be sure to look at the similar cod I didn’t comment on, those are done with the right amount of indenting
Sources/CareKitEssentials/Extensions/CareTaskProgressStrategy+Math.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
Tests/CareKitEssentialsTests/CareTaskProgressStrategynTests.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
changed the title of OCKEventAggregator.swift to CareTaskProgressStrategy+Math