Fix handling of single top tracks

This commit is contained in:
2023-06-12 17:12:10 +10:00
parent 9a38680ced
commit db48f627b4

View File

@@ -20,7 +20,13 @@ module Adamantium
tracks = lastfm.user.get_weekly_track_chart(user: "dNitza", from: start_date, to: end_date)
if track = tracks.first
track = if tracks.is_a? Array
tracks.first
else
tracks
end
if track
mb_id = track["mbid"] == {} ? "unknown" : track["mbid"]
top_track_repo.upsert(post_id: post.id, name: track["name"], artist: track.dig("artist", "content"), url: track["url"], mb_id: mb_id)
end