* restrict not null

This commit is contained in:
Seth Call 2014-03-04 11:06:53 -06:00
parent 81d3a0a540
commit 7d0ca26bda
5 changed files with 49 additions and 19 deletions

View File

@ -35,7 +35,7 @@ class JamRuby::Promotional < ActiveRecord::Base
end
def self.active(max_count=10)
rel = self.where(:aasm_state => ACTIVE_STATE)
rel = self.where(:aasm_state => ACTIVE_STATE).where('latest_id IS NOT NULL')
if 0 < (mc = max_count.to_i)
rel = rel.limit(mc)
end

View File

@ -132,7 +132,7 @@
$audio.append(originalSource);
audioDomElement = $audio.get(0);
audioBind();
logger.debug("recreated audio element ")
logger.log("recreated audio element ")
}
function clearBufferTimeout() {
@ -143,7 +143,7 @@
}
function transition(newState) {
logger.debug("transitioning from " + playState + " to " + newState);
logger.log("transitioning from " + playState + " to " + newState);
playState = newState;
@ -156,6 +156,7 @@
playState == PlayStateSessionOver ||
playState == PlayStateNetworkError ||
playState == PlayStateServerError ) {
$audio.unbind('canplay');
context.JK.ListenBroadcastCurrentlyPlaying = null;
}
@ -165,7 +166,7 @@
function noBuffer() {
if(retryAttempts >= RETRY_ATTEMPTS) {
logger.debug("never received indication of buffering or playing");
logger.log("never received indication of buffering or playing");
transition(PlayStateFailedStart);
}
else {
@ -176,7 +177,14 @@
// tell audio to stop/start, in attempt to retry
//audioDomElement.pause();
audioDomElement.load();
audioDomElement.play();
if(isDesktopSafari()) {
$audio.bind('canplay', function() {
audioDomElement.play();
})
}
else {
audioDomElement.play();
}
transition(PlayStateRetrying);
@ -199,21 +207,21 @@
function onPlaying() {
if(isNoisyEvent('playing')) return;
logger.debug("playing", arguments);
logger.log("playing", arguments);
transition(PlayStatePlaying);
}
function onPause() {
if(isNoisyEvent('pause')) return;
logger.debug("pause", arguments);
logger.log("pause", arguments);
transition(PlayStateStalled);
}
function onError() {
if(isNoisyEvent('error')) return;
logger.debug("error", arguments);
logger.log("error", arguments);
if(playState == PlayStatePlaying || playState == PlayStateStalled) {
transition(PlayStateFailedPlaying);
@ -225,27 +233,27 @@
function onEnded() {
if(isNoisyEvent('ended')) return;
logger.debug("ended", arguments);
logger.log("ended", arguments);
transition(PlayStateEnded);
}
function onEmptied() {
if(isNoisyEvent('emptied')) return;
logger.debug("emptied", arguments);
logger.log("emptied", arguments);
}
function onAbort() {
if(isNoisyEvent('abort')) return;
logger.debug("abort", arguments);
logger.log("abort", arguments);
}
function onStalled() {
if(isNoisyEvent('stalled')) return;
logger.debug("stalled", arguments);
logger.log("stalled", arguments);
if(arguments[0].target !== audioDomElement) {
logger.debug("ignoring stalled msg for non-active audio element")
logger.log("ignoring stalled msg for non-active audio element")
return;
}
// fires in Chrome on page load
@ -257,7 +265,7 @@
function onSuspend() {
if(isNoisyEvent('suspend')) return;
logger.debug("onsuspend", arguments);
logger.log("onsuspend", arguments);
// fires in FF on page load
@ -265,7 +273,7 @@
}
function onTimeUpdate() {
//logger.debug("ontimeupdate", arguments);
//logger.log("ontimeupdate", arguments);
}
function onProgress() {
@ -368,6 +376,22 @@
}
}
function isDesktopSafari() {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari') != -1) {
if (ua.indexOf('chrome') > -1) {
} else {
if (ua.match(/iPad/i) || ua.match(/iPhone/i)) {
return true; // not sure yet which way this should go
}
return true;
}
}
return false;
}
function audioBind() {
$audio.bind('play', onPlay);
$audio.bind('playing', onPlaying);
@ -380,8 +404,8 @@
$audio.bind('stalled', onStalled);
//$audio.bind('timeupdate', onTimeUpdate);
$audio.bind('progress', onProgress);
}
function initialize() {
musicSessionId = $parent.attr('data-music-session');
@ -394,7 +418,7 @@
$audio = $('audio', $parent);
if($audio.length == 0) {
logger.debug("listen_broadcast: no audio element. deactivating")
logger.log("listen_broadcast: no audio element. deactivating")
return;
}
if($audio.length > 1) {

View File

@ -11,8 +11,10 @@
text-align: center;
@include border_box_sizing;
height: 36px;
}
.recording-controls {
margin-top: 15px;
padding: 3px 5px 3px 10px;
@ -35,6 +37,10 @@
.play-button {
outline: 0;
// the following 3 properties were to make safari on iOS not wrap text after the .play-button float:left was preferred
position:absolute;
left:5px;
top:7px;
}
&.no-mount{

View File

@ -22,7 +22,7 @@
- if feed_item.has_mount?
%audio{preload: 'none'}
%source{src: feed_item.music_session.mount.url, type: feed_item.music_session.mount.resolve_string(:mime_type)}
.session-status
%span.session-status
= session_text(feed_item)
/ current playback time
= session_duration(feed_item, class: 'session-duration tick-duration recording-current', 'data-created-at' => feed_item.created_at.to_i)

View File

@ -213,6 +213,6 @@ if defined?(Bundler)
config.send_join_session_email_notifications = true
config.use_promos_on_homepage = false
config.use_promos_on_homepage = true
end
end