-
Notifications
You must be signed in to change notification settings - Fork 121
Customer Search: Coordinate Customer and CustomerSearchResults entities with Storage
#7848
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
Conversation
You can test the changes from this Pull Request by:
|
rachelmcr
left a comment
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.
Why are we adding a siteID property to WCAnalyticsCustomer? I followed how the changes to Customer support upserting everything to storage, but I don't see how the changes to WCAnalyticsCustomer fit into that. (I might be missing something here!)
Otherwise, my comments below are mostly just nits. These changes work as expected, and thanks for adding test coverage!
| public struct WCAnalyticsCustomer: Codable { | ||
| public struct WCAnalyticsCustomer: Codable, GeneratedCopiable, GeneratedFakeable { | ||
| /// The siteID for the WCAnalyticsCustomer | ||
| public let siteID: Int64 |
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.
Why are we adding a siteID property to WCAnalyticsCustomer? It's very possible I missed it, but I didn't see where we're using this. It looks like we may only need it for the Customer model.
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.
You're right that we're not actively using it at the moment. That said I'd prefer to leave it for consistency with the rest of the models, and at some point we may need to save this to storage directly and siteID will be necessary ( I just haven't reached that point yet :D ). I can always circle back once the feature is completed and remove it if needed 👍
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.
I generally prefer to wait to make changes until they're definitely needed, but you have more context about the overall changes needed for this project so I'd say go with what makes most sense for your plans here!
|
Thanks for review @rachelmcr 🙇 , feedback has been addressed and there was also a conflict with trunk that has been resolved. Ready for another look when you can! |
rachelmcr
left a comment
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! I left a comment about a point where a strong reference to self is being captured implicitly, but once that's resolved this should be good to go.
| keyword: String, | ||
| readOnlyCustomers: [Networking.Customer], | ||
| onCompletion: @escaping () -> Void) { | ||
| sharedDerivedStorage.perform { |
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.
Since we're using self.sharedDerivedStorage in the closure here, it would be good to capture weak self, rather than implicitly capturing a strong reference to self. (Another option is to assign sharedDerivedStorage to a constant in the method before using it, so you don't need a reference to self in the closure.)
| public struct WCAnalyticsCustomer: Codable { | ||
| public struct WCAnalyticsCustomer: Codable, GeneratedCopiable, GeneratedFakeable { | ||
| /// The siteID for the WCAnalyticsCustomer | ||
| public let siteID: Int64 |
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.
I generally prefer to wait to make changes until they're definitely needed, but you have more context about the overall changes needed for this project so I'd say go with what makes most sense for your plans here!
Part of: #7741
Description
This PR updates the Network's
CustomerandWCAnalyticsCustomerentities with asiteIDparameter. Then adds support for upsertingCustomerandCustomerSearchResultsto Storage.Changes
siteIDtoCustomerandWCAnalyticsCustomermodels.upsertCustomerandupsertSearchCustomerResultmethods toCustomerStore+ Unit TestsCustomer+ReadOnlyConvertibleStorageType+Extensions+ Unit TestsTesting instructions
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Creation/CustomerSection/CreateOrderAddressFormViewModel.swift
Lines 108 to 112 in ec11323