recurring loading working now
This commit is contained in:
@@ -8,21 +8,23 @@ class CreateSpotifyActivity
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def perform
|
||||
response['items'].reverse.each do |play|
|
||||
counts = response["items"].size
|
||||
Rails.logger.info("Saving #{counts} activities")
|
||||
response["items"].reverse.each do |play|
|
||||
activity = new_activity
|
||||
activity.item_ref = play['track']['id']
|
||||
artist_names = play['track']['artists'].map { |a| a['name'] }
|
||||
artists = artist_names.join(', ')
|
||||
activity.item_ref = play["track"]["id"]
|
||||
artist_names = play["track"]["artists"].map { |a| a["name"] }
|
||||
artists = artist_names.join(", ")
|
||||
title = "#{artists} - #{play['track']['name']}"
|
||||
activity.item_title = title
|
||||
activity.item_length = play['track']['duration'].to_s
|
||||
activity.started_at = DateTime.parse(play['played_at'])
|
||||
activity.save
|
||||
activity.item_length = play["track"]["duration"].to_s
|
||||
activity.started_at = DateTime.parse(play["played_at"])
|
||||
activity.save!
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def new_activity
|
||||
Activity.new(user: user, platform: 'spotify')
|
||||
Activity.new(user: user, platform: "spotify")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user