StanfordSpezi / SpeziScheduler

Scheduler Module for the Stanford Spezi Ecosystem
https://swiftpackageindex.com/StanfordSpezi/SpeziScheduler/documentation/
MIT License
3 stars 3 forks source link

Bug Fix: SpeziScheduler multiple task app crash #37

Closed karansoin closed 4 months ago

karansoin commented 4 months ago

Bug Fix: SpeziScheduler multiple task app crash

:recycle: Current situation & Problem

Fixing the following issue: https://github.com/StanfordSpezi/SpeziScheduler/issues/36

:gear: Release Notes

:books: Documentation

https://github.com/StanfordSpezi/.github/blob/main/DOCUMENTATIONGUIDE.md DETAILS: When I try to add multiple tasks in a single day in the schedule that uses SpeziScheduler, running the app causes it to crash, with the error message "Fatal error: Duplicate keys of type 'Event' were found in a Dictionary. This usually means either that the type violates Hashable's requirements, or that members of such a dictionary were mutated after insertion. The template app's PICSScheduler file (our project's version of it) initially has only the single task with static var SocialSupportTask: SpeziScheduler.Task, but I modified that to include 3 tasks instead of just 1, so it now includes: static var PHQ4Task: SpeziScheduler.Task, static var EQ5D5LTask: SpeziScheduler.Task, and static var MiniNutritionalTask: SpeziScheduler.Task

And, the final convenience init is to incorporate: convenience init() { self.init(tasks: [Self.PHQ4Task, Self.EQ5D5LTask, Self.MiniNutritionalTask])}

These changes seem to have been enough to cause the error. Full details about reasoning here: https://github.com/StanfordSpezi/SpeziScheduler/issues/36

:white_check_mark: Testing

Added a new Unit Test to SpeziScheduler to check whether the two instances of Event (once when completed, and once when not completed) produce the same hash

:pencil: Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (adf793c) 86.04% compared to head (9c77a4b) 86.18%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/37/graphs/tree.svg?width=650&height=150&src=pr&token=0VQNE0E1Wp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi)](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/37?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ```diff @@ Coverage Diff @@ ## main #37 +/- ## ========================================== + Coverage 86.04% 86.18% +0.14% ========================================== Files 7 7 Lines 716 716 ========================================== + Hits 616 617 +1 + Misses 100 99 -1 ``` | [Files](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/37?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | Coverage Δ | | |---|---|---| | [Sources/SpeziScheduler/Model/Event.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/37?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aVNjaGVkdWxlci9Nb2RlbC9FdmVudC5zd2lmdA==) | `94.78% <100.00%> (+0.66%)` | :arrow_up: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/37?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/37?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Last update [adf793c...9c77a4b](https://app.codecov.io/gh/StanfordSpezi/SpeziScheduler/pull/37?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi).