Discogs.Services.SyncUserCollection (discogs_shuffle v0.2.0) View Source
Syncs releases and associated data types and adds them to a user's collection.
Link to this section Summary
Functions
Converts Release
attribute maps into %Discogs.Release{}
structs, then
Link to this section Types
Specs
Link to this section Functions
Specs
sync( %Discogs.Models.User{ __meta__: term(), id: term(), inserted_at: term(), name: term(), records: term(), releases: term(), updated_at: term() }, [release_attrs()] ) :: {:ok, %Discogs.Models.User{ __meta__: term(), id: term(), inserted_at: term(), name: term(), records: term(), releases: term(), updated_at: term() }}
Converts Release
attribute maps into %Discogs.Release{}
structs, then:
- upserts the structs along with their associations
- removes
User
->Release
associations missing from the release list
User
-> Release
associations can be missing when a user has removed a
release from their collection, for example when a release is sold or lost.
In that case we want to make sure the association is not cast.
This could be restructured to leverage something like Ecto.Multi
and upsert
associations (Artist
s, Record
s, UserRelease
s) separately from the
Release
s.