diff --git a/db/manifest b/db/manifest
index ae595ece9..5e0250284 100755
--- a/db/manifest
+++ b/db/manifest
@@ -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
\ No newline at end of file
diff --git a/db/up/add_active_feed.rb b/db/up/add_active_feed.rb
new file mode 100644
index 000000000..725b36ec6
--- /dev/null
+++ b/db/up/add_active_feed.rb
@@ -0,0 +1 @@
+alter table feeds add column active BOOLEAN DEFAULT FALSE;
\ No newline at end of file
diff --git a/ruby/lib/jam_ruby/models/feed.rb b/ruby/lib/jam_ruby/models/feed.rb
index cd68b8bd4..c2448e511 100644
--- a/ruby/lib/jam_ruby/models/feed.rb
+++ b/ruby/lib/jam_ruby/models/feed.rb
@@ -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
diff --git a/ruby/lib/jam_ruby/models/music_session.rb b/ruby/lib/jam_ruby/models/music_session.rb
index 67e3eebe2..0095eb652 100644
--- a/ruby/lib/jam_ruby/models/music_session.rb
+++ b/ruby/lib/jam_ruby/models/music_session.rb
@@ -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
diff --git a/ruby/lib/jam_ruby/models/rsvp_request.rb b/ruby/lib/jam_ruby/models/rsvp_request.rb
index 689aad72e..f30851efe 100644
--- a/ruby/lib/jam_ruby/models/rsvp_request.rb
+++ b/ruby/lib/jam_ruby/models/rsvp_request.rb
@@ -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]
diff --git a/ruby/spec/jam_ruby/models/feed_spec.rb b/ruby/spec/jam_ruby/models/feed_spec.rb
index dc790f13c..a0ec224da 100644
--- a/ruby/spec/jam_ruby/models/feed_spec.rb
+++ b/ruby/spec/jam_ruby/models/feed_spec.rb
@@ -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
diff --git a/web/app/assets/javascripts/accounts_session_detail.js b/web/app/assets/javascripts/accounts_session_detail.js
index c43a8b537..a93d0b1c7 100644
--- a/web/app/assets/javascripts/accounts_session_detail.js
+++ b/web/app/assets/javascripts/accounts_session_detail.js
@@ -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 += '
';
+ instrumentLogoHtml += '
';
})
}
@@ -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 += '
';
+ instrumentLogoHtml += '
';
});
}
@@ -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'}
);
});
diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js
index df765fb3a..98db4761f 100644
--- a/web/app/assets/javascripts/findSession.js
+++ b/web/app/assets/javascripts/findSession.js
@@ -85,6 +85,9 @@
context.JK.bindHoverEvents();
$ssSpinner.hide();
});
+
+ // context.JK.bindInstrumentHover($(CATEGORY.ACTIVE.id));
+ // context.JK.bindInstrumentHover($(CATEGORY.SCHEDULED.id));
}
/***************** ACTIVE SESSIONS *****************/
diff --git a/web/app/assets/javascripts/jamkazam.js b/web/app/assets/javascripts/jamkazam.js
index 08d79d34a..d8fb6e4aa 100644
--- a/web/app/assets/javascripts/jamkazam.js
+++ b/web/app/assets/javascripts/jamkazam.js
@@ -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 {
diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js
index 06d26efa6..d58218dbf 100644
--- a/web/app/assets/javascripts/sessionList.js
+++ b/web/app/assets/javascripts/sessionList.js
@@ -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 += '
';
+ instrumentLogoHtml += '
';
}
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 += '
';
+ instrumentLogoHtml += '
';
}
}
diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js
index b83d901c7..2afdd2f53 100644
--- a/web/app/assets/javascripts/utils.js
+++ b/web/app/assets/javascripts/utils.js
@@ -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 {
diff --git a/web/spec/controllers/api_feeds_controller_spec.rb b/web/spec/controllers/api_feeds_controller_spec.rb
index e6b73e23f..2437e5d14 100644
--- a/web/spec/controllers/api_feeds_controller_spec.rb
+++ b/web/spec/controllers/api_feeds_controller_spec.rb
@@ -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