Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

WIP feat: each track.url update matching providerTrack #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

4www
Copy link

@4www 4www commented Jun 23, 2018

This PR has for objective:

  • each time a track model's url is changed in the Radio4000 Firebase database, it will trigger a function that will create a matching providerTrack in the database, with for id: provider:providerId.
  • when a track is deleted, it's reference under providerTracks/$providerTrack should be deleted.

@4www 4www force-pushed the feat/unique-tracks branch from 3900742 to 2c220dc Compare June 23, 2018 17:03
return false
}

const ref = db.ref(`/providerTracks/${providerName}:${providerId}/tracks/${context.params.trackId}`);
Copy link
Member

@oskarrough oskarrough Jun 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about splitting providerName and providerId with a slash as well? Instead of the :. So you don't have to parse the string to figure out which provider it is. Easier to query with firebase I assume.

ala

https://media.now.sh/youtube/YyI52_FEYgY
https://media.now.sh/vimeo/121814744
https://media.now.sh/discogs/1728315

Copy link
Author

@4www 4www Jun 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the DB looks like this

- providerTracks
- - youtube:OkR7UNnQU6c

So if you want to query it with ember your just do store.find('providerTrack', 'youtube:OkR7UNnQU6c').

If you separate the provider with a slash how would you query the providerTrack that has the youtube id OkR7UNnQU6c?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Not sure how to query that either. Maybe different models. Each extend providerTrack so the adapter can specify the endpoints: this.store.find('youtube-track', id)? Ala what we do on the Explorer for Discogs.


If we have discogs:123 and youtube:456. How do you query all Discogs tracks?

Another idea is to move the provider to to a property? {id: '123', provider: 'youtube'}. Then it's easy to filter and query. Trying to think of the pros and cons..

Copy link
Author

@4www 4www Jun 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that there is a misunderstanding on the point of this new model.

I will try to make a summary to explain the idea better.

// Listen to every track change
exports.onTrackUrlChange =
functions.database.ref('/tracks/{trackId}/url')
.onWrite(onTrackUrlChange)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does onWrite mean create+update? Does it also include delete?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onWrite(), which triggers when data is created, updated, or deleted in the Realtime Database.
Source: https://firebase.google.com/docs/functions/database-events

@4www 4www changed the title feat: each track.url update matching providerTrack WIP feat: each track.url update matching providerTrack Jun 23, 2018
@4www 4www closed this Jun 24, 2018
@4www 4www reopened this Aug 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants