From 53f7f29c06740eccae88a71873c9cbaadfd34ba3 Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Fri, 4 Dec 2015 05:26:26 +0000 Subject: [PATCH] VRFS-3728 ios client sync api tweaks --- ruby/lib/jam_ruby/models/jam_track.rb | 3 ++- web/app/controllers/api_jam_tracks_controller.rb | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ruby/lib/jam_ruby/models/jam_track.rb b/ruby/lib/jam_ruby/models/jam_track.rb index 2bbb8b698..bf200cfd7 100644 --- a/ruby/lib/jam_ruby/models/jam_track.rb +++ b/ruby/lib/jam_ruby/models/jam_track.rb @@ -477,13 +477,14 @@ module JamRuby .where(user_id: user_id) .order('created_at DESC') .limit(1) - jtx_created.created_at.to_i + jtx_created.first.created_at.to_i end def self.mixdownChecksum(user_id, jam_track_id) dates = JamTrackMixdown .select('created_at') .where(user_id: user_id, jam_track_id: jam_track_id) + .order(:id) dates = dates.map do |date| date.created_at.to_i.to_s diff --git a/web/app/controllers/api_jam_tracks_controller.rb b/web/app/controllers/api_jam_tracks_controller.rb index 0d0b03c26..e8de18f44 100644 --- a/web/app/controllers/api_jam_tracks_controller.rb +++ b/web/app/controllers/api_jam_tracks_controller.rb @@ -106,20 +106,19 @@ class ApiJamTracksController < ApiController else # if the requested jamtrack is not purchased, send status code 204 if 0 == JamTrack.where(id: jtid, user_id: current_user.id).count - head(204) + head(:no_content) return end end elsif params[:syncbuys] syncbuys = params[:syncbuys].to_i - if 0 == syncbuys - head(204) - return - end latestPurchase = JamTrack.latestPurchase(current_user.id) - if 0 < latestPurchase && (latestPurchase < syncbuys) - head 204, latestpurchase: latestPurchase + if 0 == syncbuys || (0 < latestPurchase && (latestPurchase <= syncbuys)) + head :no_content, latestpurchase: latestPurchase return + else + head :ok, latestpurchase: latestPurchase + return end end head(:ok)