mozilla-mobile / prox

[INACTIVE] A search and discovery app for the "here & now". We're experimenting with ideas on mobile that can better surface content from the open web.
https://wiki.mozilla.org/New_Mobile_Experience
Mozilla Public License 2.0
22 stars 12 forks source link

Closes #506 - Iterate through provider sources on the client #507

Closed thebnich closed 7 years ago

thebnich commented 7 years ago

A big diff, but most of this is straightforward refactoring that moves the Firebase data extraction from Place.swift into the new PlaceProviders.swift. This creates a new protocol, PlaceProvider, that contains all of the fields a provider might have. Note that all fields are optional, so there's no requirement that any provider gives any particular fields.

The primary implementation of this protocol is SourcePlaceProvider, which pulls provider info from the Firebase dict (most of this was simply taken from the Place initializer). The other implementation is the CompositePlaceProvider, which takes a list of providers (ordered by priority) and sets each field based on the first source where it's available. Since Yelp is currently the only provider for each place, the CompositePlaceProvider will just be a mirror of Yelp results, but this will of course change once TA/Wikipedia are added.

Once we have our CompositePlaceProvider, we can populate our Place fields as normal. Like before, we require that we have at least an ID, name, and lat/long pair for a place.

Note: I think Yelp data will divided into both Yelp v2 and Yelp v3 data in Firebase (under providers/yelp and providers/yelpv3), where we currently have only v2 data. I don't think we want separate Yelp v2/v3 providers exposed in a Place, though, so I expect that once we have v3 data, yelpProvider will itself be a CompositePlaceProvider populated from the providers/yelp and providers/yelpv3 branches.

mcomella commented 7 years ago

btw, if you name your commits "Closes #" instead of "Issue #", the associated github issue will close automatically when the changes are merged.