VRFS-1333 play tracking
This commit is contained in:
parent
1eb4b80482
commit
46b0832cd8
|
|
@ -93,9 +93,9 @@
|
|||
});
|
||||
}
|
||||
|
||||
function addRecordingPlay(recordingId, claimedRecordingId, userId) {
|
||||
function addPlayablePlay(playableId, claimedRecordingId, userId) {
|
||||
return $.ajax({
|
||||
url: '/api/recordings/' + recordingId + "/plays",
|
||||
url: '/api/users/' + playableId + "/plays",
|
||||
type: "POST",
|
||||
data : JSON.stringify({user_id: userId, claimed_recording_id: claimedRecordingId}),
|
||||
dataType : 'json',
|
||||
|
|
@ -904,7 +904,7 @@
|
|||
this.addSessionLike = addSessionLike;
|
||||
this.addRecordingComment = addRecordingComment;
|
||||
this.addRecordingLike = addRecordingLike;
|
||||
this.addRecordingPlay = addRecordingPlay;
|
||||
this.addPlayablePlay = addPlayablePlay;
|
||||
this.getSession = getSession;
|
||||
this.getClientDownloads = getClientDownloads;
|
||||
this.createEmailInvitations = createEmailInvitations;
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@
|
|||
transition(PlayStateInitializing);
|
||||
// keep this after transition, because any transition clears this timer
|
||||
waitForBufferingTimeout = setTimeout(noBuffer, WAIT_FOR_BUFFER_TIMEOUT);
|
||||
//context.JK.Rest().addPlayablePlay(null, null, context.JK.currentUserId);
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
function pause(e) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
}
|
||||
|
||||
function play() {
|
||||
rest.addRecordingPlay(recordingId, claimedRecordingId, JK.currentUserId)
|
||||
rest.addPlayablePlay(recordingId, claimedRecordingId, JK.currentUserId)
|
||||
.done(function(response) {
|
||||
$("#spnPlayCount", $scope).html(parseInt($("#spnPlayCount").text()) + 1);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -152,8 +152,9 @@ class ApiRecordingsController < ApiController
|
|||
return
|
||||
end
|
||||
|
||||
play = RecordingPlay.new
|
||||
play.recording_id = params[:id]
|
||||
play = PlayablePlay.new
|
||||
play.playable_id = params[:id]
|
||||
play.playable_type = 'JamRuby::Recording'
|
||||
play.player_id = params[:user_id]
|
||||
play.claimed_recording_id = params[:claimed_recording_id]
|
||||
play.ip_address = request.remote_ip
|
||||
|
|
|
|||
|
|
@ -572,6 +572,29 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
end
|
||||
|
||||
def add_play
|
||||
if params[:id].blank?
|
||||
render :json => { :message => "Playable ID is required" }, :status => 400
|
||||
return
|
||||
end
|
||||
|
||||
play = PlayablePlay.new
|
||||
play.playable_id = params[:id]
|
||||
play.playable_type = params[:claimed_recording_id].present? ? 'JamRuby::Recording' : 'JamRuby::MusicSession'
|
||||
play.player_id = params[:user_id]
|
||||
play.claimed_recording_id = params[:claimed_recording_id]
|
||||
play.ip_address = request.remote_ip
|
||||
play.save
|
||||
|
||||
if play.errors.any?
|
||||
render :json => { :message => "Unexpected error occurred" }, :status => 500
|
||||
return
|
||||
else
|
||||
render :json => {}, :status => 201
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
###################### RECORDINGS #######################
|
||||
# def recording_index
|
||||
# @recordings = User.recording_index(current_user, params[:id])
|
||||
|
|
|
|||
|
|
@ -225,6 +225,8 @@ SampleApp::Application.routes.draw do
|
|||
# match '/users/:id/recordings/:recording_id' => 'api_users#recording_update', :via => :post
|
||||
# match '/users/:id/recordings/:recording_id' => 'api_users#recording_destroy', :via => :delete
|
||||
|
||||
match '/users/:id/plays' => 'api_users#add_play', :via => :post, :as => 'api_users_add_play'
|
||||
|
||||
# bands
|
||||
match '/bands' => 'api_bands#index', :via => :get
|
||||
match '/bands/validate' => 'api_bands#validate', :via => :post
|
||||
|
|
@ -304,7 +306,6 @@ SampleApp::Application.routes.draw do
|
|||
match '/recordings/:id/claim' => 'api_recordings#claim', :via => :post, :as => 'api_recordings_claim'
|
||||
match '/recordings/:id/comments' => 'api_recordings#add_comment', :via => :post, :as => 'api_recordings_add_comment'
|
||||
match '/recordings/:id/likes' => 'api_recordings#add_like', :via => :post, :as => 'api_recordings_add_like'
|
||||
match '/recordings/:id/plays' => 'api_recordings#add_play', :via => :post, :as => 'api_recordings_add_play'
|
||||
match '/recordings/:id/discard' => 'api_recordings#discard', :via => :post, :as => 'api_recordings_discard'
|
||||
match '/recordings/:id/tracks/:track_id/download' => 'api_recordings#download', :via => :get, :as => 'api_recordings_download'
|
||||
match '/recordings/:id/tracks/:track_id/upload_next_part' => 'api_recordings#upload_next_part', :via => :get
|
||||
|
|
|
|||
|
|
@ -359,11 +359,7 @@ FactoryGirl.define do
|
|||
token_expires_at Time.now
|
||||
end
|
||||
|
||||
factory :recording_play, :class => JamRuby::RecordingPlay do
|
||||
|
||||
end
|
||||
|
||||
factory :music_session_play, :class => JamRuby::MusicSessionPlay do
|
||||
factory :playable_play, :class => JamRuby::PlayablePlay do
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue