Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop
This commit is contained in:
commit
d5eeb03bd3
|
|
@ -216,4 +216,4 @@ fix_find_session_sorting_2216c.sql
|
|||
entabulate_current_network_scores.sql
|
||||
discard_scores_changed.sql
|
||||
emails_from_update.sql
|
||||
|
||||
add_active_feed.rb
|
||||
|
|
@ -0,0 +1 @@
|
|||
alter table feeds add column active BOOLEAN DEFAULT FALSE;
|
||||
|
|
@ -47,13 +47,13 @@ module JamRuby
|
|||
# handle sort
|
||||
if sort == 'date'
|
||||
query = query.where("feeds.id < #{start}")
|
||||
query = query.order('feeds.id DESC')
|
||||
query = query.order('feeds.active DESC, feeds.id DESC')
|
||||
elsif sort == 'plays'
|
||||
query = query.offset(start)
|
||||
query = query.order("COALESCE(recordings.play_count, music_sessions.play_count) DESC ")
|
||||
query = query.order("feeds.active DESC, COALESCE(recordings.play_count, music_sessions.play_count) DESC")
|
||||
elsif sort == 'likes'
|
||||
query = query.offset(start)
|
||||
query = query.order("COALESCE(recordings.like_count, music_sessions.like_count) DESC ")
|
||||
query = query.order("feeds.active DESC, COALESCE(recordings.like_count, music_sessions.like_count) DESC")
|
||||
else
|
||||
raise "sort not implemented: #{sort}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ module JamRuby
|
|||
def add_to_feed
|
||||
feed = Feed.new
|
||||
feed.music_session = self
|
||||
feed.active = true
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -604,6 +605,12 @@ module JamRuby
|
|||
|
||||
hist.end_history if hist
|
||||
|
||||
feed = Feed.find_by_music_session_id(session_id)
|
||||
unless feed.nil?
|
||||
feed.active = false
|
||||
feed.save
|
||||
end
|
||||
|
||||
Notification.send_session_ended(session_id)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
if rsvp_slot.chosen && r[:accept]
|
||||
raise StateError, "The #{rsvp_slot.instrument_id} slot has already been approved for another user."
|
||||
raise StateError, "All RSVP slots for the #{rsvp_slot.instrument_id} have been already approved."
|
||||
end
|
||||
|
||||
if r[:accept]
|
||||
|
|
|
|||
|
|
@ -54,16 +54,16 @@ describe Feed do
|
|||
end
|
||||
|
||||
describe "sorting" do
|
||||
it "sorts by index (date) DESC" do
|
||||
it "sorts by active flag / index (date) DESC" do
|
||||
claimed_recording = FactoryGirl.create(:claimed_recording)
|
||||
|
||||
feeds, start = Feed.index(user1)
|
||||
feeds.length.should == 2
|
||||
feeds[0].recording.should == claimed_recording.recording
|
||||
feeds[1].music_session.should == claimed_recording.recording.music_session.music_session
|
||||
feeds[1].recording.should == claimed_recording.recording
|
||||
feeds[0].music_session.should == claimed_recording.recording.music_session.music_session
|
||||
end
|
||||
|
||||
it "sort by plays DESC" do
|
||||
it "sort by active flag / plays DESC" do
|
||||
claimed_recording1 = FactoryGirl.create(:claimed_recording)
|
||||
claimed_recording2 = FactoryGirl.create(:claimed_recording)
|
||||
|
||||
|
|
@ -77,8 +77,8 @@ describe Feed do
|
|||
|
||||
feeds, start = Feed.index(user1, :sort => 'plays')
|
||||
feeds.length.should == 4
|
||||
feeds[0].recording.should == claimed_recording2.recording
|
||||
feeds[1].recording.should == claimed_recording1.recording
|
||||
feeds[2].recording.should == claimed_recording2.recording
|
||||
feeds[3].recording.should == claimed_recording1.recording
|
||||
|
||||
FactoryGirl.create(:playable_play, playable: claimed_recording1.recording.music_session.music_session, user: user1)
|
||||
FactoryGirl.create(:playable_play, playable: claimed_recording1.recording.music_session.music_session, user: user2)
|
||||
|
|
@ -88,11 +88,11 @@ describe Feed do
|
|||
feeds, start = Feed.index(user1, :sort => 'plays')
|
||||
feeds.length.should == 4
|
||||
feeds[0].music_session.should == claimed_recording1.recording.music_session.music_session
|
||||
feeds[1].recording.should == claimed_recording2.recording
|
||||
feeds[2].recording.should == claimed_recording1.recording
|
||||
feeds[2].recording.should == claimed_recording2.recording
|
||||
feeds[3].recording.should == claimed_recording1.recording
|
||||
end
|
||||
|
||||
it "sort by likes DESC" do
|
||||
it "sort by active flag / likes DESC" do
|
||||
claimed_recording1 = FactoryGirl.create(:claimed_recording)
|
||||
claimed_recording2 = FactoryGirl.create(:claimed_recording)
|
||||
|
||||
|
|
@ -106,6 +106,7 @@ describe Feed do
|
|||
|
||||
feeds, start = Feed.index(user1, :sort => 'likes')
|
||||
feeds.length.should == 4
|
||||
feeds = feeds.where("feeds.music_session_id is null")
|
||||
feeds[0].recording.should == claimed_recording2.recording
|
||||
feeds[1].recording.should == claimed_recording1.recording
|
||||
|
||||
|
|
@ -116,8 +117,8 @@ describe Feed do
|
|||
feeds, start = Feed.index(user1, :sort => 'likes')
|
||||
feeds.length.should == 4
|
||||
feeds[0].music_session.should == claimed_recording1.recording.music_session.music_session
|
||||
feeds[1].recording.should == claimed_recording2.recording
|
||||
feeds[2].recording.should == claimed_recording1.recording
|
||||
feeds[2].recording.should == claimed_recording2.recording
|
||||
feeds[3].recording.should == claimed_recording1.recording
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -195,6 +196,8 @@ describe Feed do
|
|||
it "supports date pagination" do
|
||||
claimed_recording = FactoryGirl.create(:claimed_recording)
|
||||
|
||||
MusicSession.removed_music_session(claimed_recording.recording.music_session.music_session.id)
|
||||
|
||||
options = {limit: 1}
|
||||
feeds, start = Feed.index(user1, options)
|
||||
feeds.length.should == 1
|
||||
|
|
|
|||
|
|
@ -101,7 +101,18 @@
|
|||
|
||||
rest.updateRsvpRequest(rsvpId, params)
|
||||
.done(refreshSessionDetail)
|
||||
.fail(app.ajaxError);
|
||||
.fail(function(jqXHR, textStatus, errorMessage) {
|
||||
if (jqXHR.status === 400) {
|
||||
app.notify(
|
||||
{
|
||||
title: "Unable to Approve RSVP",
|
||||
text: jqXHR.responseJSON.message
|
||||
});
|
||||
}
|
||||
else {
|
||||
app.ajaxError(jqXHR, textStatus, errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function declineRsvpRequest(e) {
|
||||
|
|
@ -132,6 +143,9 @@
|
|||
});
|
||||
|
||||
context.JK.bindHoverEvents();
|
||||
// context.JK.bindInstrumentHover($('#pendingRSVPs'));
|
||||
// context.JK.bindInstrumentHover($('#session-rsvps'));
|
||||
// context.JK.bindInstrumentHover($('#still-needed'));
|
||||
}
|
||||
|
||||
function loadSessionData() {
|
||||
|
|
@ -243,7 +257,7 @@
|
|||
$.each(pending_rsvp_request.instrument_list, function (index, instrument) {
|
||||
var instrumentId = instrument == null ? null : instrument.id;
|
||||
var inst = context.JK.getInstrumentIcon24(instrumentId);
|
||||
instrumentLogoHtml += '<img data-instrument-id="' + instrumentId + '" src="' + inst + '" width="24" height="24" /> ';
|
||||
instrumentLogoHtml += '<img title="' + instrumentId + '" hoveraction="instrument" data-instrument-id="' + instrumentId + '" src="' + inst + '" width="24" height="24" /> ';
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -281,7 +295,7 @@
|
|||
$.each(approved_rsvp.instrument_list, function(index, instrument) {
|
||||
var instrumentId = instrument == null ? null : instrument.id;
|
||||
var inst = context.JK.getInstrumentIcon24(instrumentId);
|
||||
instrumentLogoHtml += '<img src="' + inst + '" width="24" height="24" /> ';
|
||||
instrumentLogoHtml += '<img title="' + instrumentId + '" hoveraction="instrument" data-instrument-id="' + instrumentId + '" src="' + inst + '" width="24" height="24" /> ';
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +326,7 @@
|
|||
|
||||
rsvpHtml = context._.template(
|
||||
$("#template-account-session-rsvp").html(),
|
||||
{id: approved_rsvp.id, user_id: approved_rsvp.user_id, avatar_url: avatar_url,
|
||||
{id: approved_rsvp.id, avatar_url: avatar_url,
|
||||
user_name: approved_rsvp.name, instruments: instrumentLogoHtml,
|
||||
latency: latencyHtml, is_owner: sessionData.isOwner, request_id: request_id},
|
||||
{variable: 'data'}
|
||||
|
|
@ -346,7 +360,7 @@
|
|||
|
||||
resultHtml += context._.template(
|
||||
$("#template-account-invited").html(),
|
||||
{avatar_url: avatar_url, user_id: invitation.reciever_id},
|
||||
{avatar_url: avatar_url, user_id: invitation.receiver_id},
|
||||
{variable: 'data'}
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@
|
|||
context.JK.bindHoverEvents();
|
||||
$ssSpinner.hide();
|
||||
});
|
||||
|
||||
// context.JK.bindInstrumentHover($(CATEGORY.ACTIVE.id));
|
||||
// context.JK.bindInstrumentHover($(CATEGORY.SCHEDULED.id));
|
||||
}
|
||||
|
||||
/***************** ACTIVE SESSIONS *****************/
|
||||
|
|
|
|||
|
|
@ -123,11 +123,11 @@
|
|||
*/
|
||||
function ajaxError(jqXHR, textStatus, errorMessage) {
|
||||
|
||||
if (jqXHR.status == 404) {
|
||||
if (jqXHR.status === 404) {
|
||||
logger.error("Unexpected ajax error: " + textStatus + ", msg:" + errorMessage);
|
||||
app.notify({title: "Oops!", text: "What you were looking for is gone now."});
|
||||
}
|
||||
else if (jqXHR.status = 422) {
|
||||
else if (jqXHR.status === 422) {
|
||||
logger.error("Unexpected ajax error: " + textStatus + ", msg: " + errorMessage + ", response: " + jqXHR.responseText);
|
||||
// present a nicer message
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@
|
|||
var track = participant.tracks[j];
|
||||
logger.debug("Find:Finding instruments. Participant tracks:", participant.tracks);
|
||||
var inst = context.JK.getInstrumentIcon24(track.instrument_id);
|
||||
instrumentLogoHtml += '<img src="' + inst + '" width="24" height="24" /> ';
|
||||
instrumentLogoHtml += '<img title="' + track.instrument_id + '" hoveraction="instrument" data-instrument-id="' + track.instrument_id + '" src="' + inst + '" width="24" height="24" /> ';
|
||||
}
|
||||
|
||||
var id = participant.user.id;
|
||||
|
|
@ -400,7 +400,7 @@
|
|||
for (j=0; j < user.instrument_list.length; j++) {
|
||||
var instrument = user.instrument_list[j];
|
||||
var inst = context.JK.getInstrumentIcon24(instrument.id);
|
||||
instrumentLogoHtml += '<img src="' + inst + '" width="24" height="24" /> ';
|
||||
instrumentLogoHtml += '<img title="' + instrument.id + '" hoveraction="instrument" data-instrument-id="' + instrument.id + '" src="' + inst + '" width="24" height="24" /> ';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,6 +239,9 @@
|
|||
var instrumentId = $element.attr('data-instrument-id');
|
||||
|
||||
if(instrumentId) {
|
||||
if (instrumentId === "null") {
|
||||
instrumentId = "not specified";
|
||||
}
|
||||
context.JK.hoverBubble($element, instrumentId, options);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ describe ApiFeedsController do
|
|||
claimed_recording.recording.created_at = 3.days.ago
|
||||
claimed_recording.recording.save!
|
||||
|
||||
MusicSession.removed_music_session(claimed_recording.recording.music_session.music_session.id)
|
||||
|
||||
get :index, { limit: 1 }
|
||||
json = JSON.parse(response.body, :symbolize_names => true)
|
||||
json[:entries].length.should == 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue