erikdstock / tipjar

tip bands since you don't pay for music any more.
MIT License
0 stars 0 forks source link

Get up-to-date monthly artists for a user #4

Closed erikdstock closed 8 years ago

erikdstock commented 8 years ago

This is a major ticket to get a user's top artists on a calendar month basis- once finished, it should be much simpler to do the same for other listening stats apis by simply writing the relevent code for their wrapper classes.

This feature overwrites the activeRecord getter method for monthly top artists. #monthly_top_artists(time) is the entry point. Basic logic:

the expected structure from the api wrapper looks like:

[
  {
    name: "A Band",
    play_count: 50,
    image: "link to artist image",
  },
  { ... },
]
erikdstock commented 8 years ago

I simplified api testing with the vcr gem and moved our api secret keys to application.yml with the figaro gem. this was necessary to avoid a bunch of hacky stuff in travis since the vcr gem couldn't match the blocked http request when Rails.application.secrets.lastfm_id was returning nil (not an issue with Webmock)

To test this you will need to rebundle, bundle exec figaro install and move our development lastfm api keys from secrets.yml to the top-level of config/application.yml like

lastfm_id: foo
lastfm_secret: bar
erikdstock commented 8 years ago

I finished this without adding an artist image- since we are pulling from tracks the image would be an album cover and i'm not sure we want that- plus it would be constantly refreshing artist images needlessly.