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

Zorr/rewrite tbakit tbadata #940

Draft
wants to merge 4 commits into
base: four
Choose a base branch
from

Conversation

ZachOrr
Copy link
Member

@ZachOrr ZachOrr commented Jun 18, 2022

Notes

throw in findOrCreate

API models might have other dependent API models. Ex: An Award needs an Event. The Award's insert method might look like the following -

static func insert(_ model: APIAward, in context: NSManagedObjectContext) async throws -> TBAAward {
  let predicate = ...
  return try await findOrCreate(in: context, matching: predicate) { (award) in
    award.event = try TBAEvent.insert(model.eventKey, in: context)
  }
}

We do a findOrCreate via the Event.insert method as opposed to passing the TBAEvent during the TBAAward.insert because the context of inserting an Award does not guarantee having an Event object.

This insert is problematic though because the insert can throw. Even in a minimal situation where we insert an Event object with just a key, our Core Data fetch (the find half of findOrCreate) can fail.

Misc

  • Consider insert in insert methods failing - should be able to fail gracefully (in some situations)
  • Add TBAEvent key unique constraint back
  • Swap asyncMap to using async collection methods in iOS 16
  • Audit isOrphaned to use TBAWebcast implementation

@ZachOrr ZachOrr changed the base branch from master to four June 18, 2022 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant