From 8f7a959a9e03f61eb2fb8f81e6ff9798ccbbc74f Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Wed, 15 Jan 2014 03:56:46 -0600 Subject: [PATCH 01/37] vrfs152: relaxed requirement for an email address --- ruby/lib/jam_ruby/models/invited_user.rb | 5 +++-- ruby/lib/jam_ruby/models/invited_user_observer.rb | 4 ++-- ruby/spec/jam_ruby/models/invited_user_spec.rb | 6 ++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ruby/lib/jam_ruby/models/invited_user.rb b/ruby/lib/jam_ruby/models/invited_user.rb index 6481a6bdb..19a7dc148 100644 --- a/ruby/lib/jam_ruby/models/invited_user.rb +++ b/ruby/lib/jam_ruby/models/invited_user.rb @@ -14,13 +14,14 @@ module JamRuby belongs_to :sender , :inverse_of => :invited_users, :class_name => "JamRuby::User", :foreign_key => "sender_id" # who is the invitation sent to? - validates :email, :presence => true, format: {with: VALID_EMAIL_REGEX} + validates :email, format: {with: VALID_EMAIL_REGEX}, :if => lambda { |iu| iu.email.present? } validates :autofriend, :inclusion => {:in => [nil, true, false]} validates :invitation_code, :presence => true validates :note, length: {maximum: 400}, no_profanity: true # 400 == arbitrary. validate :valid_personalized_invitation - validate :not_accepted_twice + # validate :not_accepted_twice + validate :not_accepted_twice, :if => lambda { |iu| iu.email } validate :can_invite? after_save :track_user_progression diff --git a/ruby/lib/jam_ruby/models/invited_user_observer.rb b/ruby/lib/jam_ruby/models/invited_user_observer.rb index a4a007a93..cd62bd2d1 100644 --- a/ruby/lib/jam_ruby/models/invited_user_observer.rb +++ b/ruby/lib/jam_ruby/models/invited_user_observer.rb @@ -8,7 +8,7 @@ module JamRuby InvitedUserMailer.welcome_betauser(invited_user).deliver else InvitedUserMailer.friend_invitation(invited_user).deliver - end + end if invited_user.email.present? end end -end \ No newline at end of file +end diff --git a/ruby/spec/jam_ruby/models/invited_user_spec.rb b/ruby/spec/jam_ruby/models/invited_user_spec.rb index 0ccf6865e..369608c11 100644 --- a/ruby/spec/jam_ruby/models/invited_user_spec.rb +++ b/ruby/spec/jam_ruby/models/invited_user_spec.rb @@ -104,4 +104,10 @@ describe InvitedUser do invited_user.valid?.should be_false end + it 'accepts empty emails' do + user1 = FactoryGirl.create(:user) + invited_user = FactoryGirl.create(:invited_user, :sender => user1, :email => '') + expect(invited_user.valid?).to eq(true) + end + end From 42713f4c9d8384cdbcf5156491cf66244d9db9cf Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Wed, 15 Jan 2014 04:10:13 -0600 Subject: [PATCH 02/37] vrfs152: allowing invited_users to have null email --- db/manifest | 3 ++- db/up/invited_users_allow_email_null.sql | 1 + ruby/lib/jam_ruby/models/invited_user.rb | 1 + web/app/controllers/users_controller.rb | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 db/up/invited_users_allow_email_null.sql diff --git a/db/manifest b/db/manifest index 8e39f5b24..77ec23aca 100755 --- a/db/manifest +++ b/db/manifest @@ -90,4 +90,5 @@ mix_job_watch.sql music_session_constraints.sql mixes_drop_manifest_add_retry.sql music_sessions_unlogged.sql -integrate_icecast_into_sessions.sql \ No newline at end of file +integrate_icecast_into_sessions.sql +invited_users_allow_email_null.sql diff --git a/db/up/invited_users_allow_email_null.sql b/db/up/invited_users_allow_email_null.sql new file mode 100644 index 000000000..ff6042710 --- /dev/null +++ b/db/up/invited_users_allow_email_null.sql @@ -0,0 +1 @@ +ALTER TABLE invited_users ALTER COLUMN email DROP NOT NULL; diff --git a/ruby/lib/jam_ruby/models/invited_user.rb b/ruby/lib/jam_ruby/models/invited_user.rb index 19a7dc148..cf401ba08 100644 --- a/ruby/lib/jam_ruby/models/invited_user.rb +++ b/ruby/lib/jam_ruby/models/invited_user.rb @@ -68,5 +68,6 @@ module JamRuby def not_accepted_twice errors.add(:accepted, "you can only accept an invitation once") if accepted_twice end + end end diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index 1192408f7..24411b3d4 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -29,7 +29,7 @@ class UsersController < ApplicationController @invited_user = load_invited_user(params) - if !@invited_user.nil? && @invited_user.accepted + if !@invited_user.nil? && @invited_user.email && @invited_user.accepted # short-circuit out if this invitation is already accepted render "already_signed_up", :layout => 'landing' return From 8f5a2a636911b6cbc6be6fa8eb6da5686094d4ee Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 26 Jan 2014 14:46:11 -0600 Subject: [PATCH 03/37] * tell NOKOGIRI to use system libraries in build environment --- admin/Gemfile | 1 + ruby/Gemfile | 17 ++++++++++------- web/Gemfile | 1 + websocket-gateway/Gemfile | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/admin/Gemfile b/admin/Gemfile index a14387965..7ca5eda28 100644 --- a/admin/Gemfile +++ b/admin/Gemfile @@ -11,6 +11,7 @@ else gem 'jam_db', "0.1.#{ENV["BUILD_NUMBER"]}" gem 'jampb', "0.1.#{ENV["BUILD_NUMBER"]}" gem 'jam_ruby', "0.1.#{ENV["BUILD_NUMBER"]}" + ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true" end gem 'rails' diff --git a/ruby/Gemfile b/ruby/Gemfile index f8a1643ac..b73acf642 100644 --- a/ruby/Gemfile +++ b/ruby/Gemfile @@ -6,6 +6,15 @@ end devenv = ENV["BUILD_NUMBER"].nil? # Jenkins sets a build number environment variable +if devenv + gem 'jam_db', :path=> "../db/target/ruby_package" + gem 'jampb', :path => "../pb/target/ruby/jampb" +else + gem 'jam_db' + gem 'jampb' + ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true" +end + gem 'pg', '0.15.1', :platform => [:mri, :mswin, :mingw] gem 'jdbc_postgres', :platform => [:jruby] @@ -33,13 +42,7 @@ gem 'resque-lonely_job', '~> 1.0.0' gem 'oj' gem 'builder' -if devenv - gem 'jam_db', :path=> "../db/target/ruby_package" - gem 'jampb', :path => "../pb/target/ruby/jampb" -else - gem 'jam_db' - gem 'jampb' -end + group :test do gem "factory_girl", '4.1.0' diff --git a/web/Gemfile b/web/Gemfile index c99aa6213..9cf724965 100644 --- a/web/Gemfile +++ b/web/Gemfile @@ -17,6 +17,7 @@ else gem 'jampb', "0.1.#{ENV["BUILD_NUMBER"]}" gem 'jam_ruby', "0.1.#{ENV["BUILD_NUMBER"]}" gem 'jam_websockets', "0.1.#{ENV["BUILD_NUMBER"]}" + ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true" end gem 'builder' gem 'rails', '>=3.2.11' diff --git a/websocket-gateway/Gemfile b/websocket-gateway/Gemfile index 78131b08a..52e8dd565 100644 --- a/websocket-gateway/Gemfile +++ b/websocket-gateway/Gemfile @@ -15,6 +15,7 @@ else gem 'jam_db', "0.1.#{ENV["BUILD_NUMBER"]}" gem 'jampb', "0.1.#{ENV["BUILD_NUMBER"]}" gem 'jam_ruby', "0.1.#{ENV["BUILD_NUMBER"]}" + ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true" end From 998ebfdc6cbbf087ed8c3c94669bf60f4b87df6b Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 26 Jan 2014 16:46:41 -0500 Subject: [PATCH 04/37] VRFS-986 landing page sidebar complete / session landing fixes --- ruby/lib/jam_ruby/models/band.rb | 11 +- .../jam_ruby/models/music_session_history.rb | 12 +- ruby/lib/jam_ruby/models/recorded_track.rb | 3 + ruby/lib/jam_ruby/models/track.rb | 10 ++ ruby/lib/jam_ruby/models/user.rb | 11 +- .../stylesheets/client/screen_common.css.scss | 123 ++++++++---------- web/app/assets/stylesheets/web/main.css.scss | 17 ++- .../assets/stylesheets/web/sessions.css.scss | 17 +++ web/app/views/music_sessions/show.html.erb | 28 ++-- web/app/views/recordings/show.html.erb | 2 +- .../views/shared/_landing_sidebar.html.erb | 67 ++++++---- web/app/views/shared/_track_details.html.erb | 6 +- web/config/environments/development.rb | 2 +- 13 files changed, 186 insertions(+), 123 deletions(-) diff --git a/ruby/lib/jam_ruby/models/band.rb b/ruby/lib/jam_ruby/models/band.rb index 1ae5b26a0..e40817623 100644 --- a/ruby/lib/jam_ruby/models/band.rb +++ b/ruby/lib/jam_ruby/models/band.rb @@ -63,8 +63,15 @@ module JamRuby end def recent_history - recordings = ClaimedRecording.joins(:recordings).where(:recordings => {:band_id => "#{self.id}"}).limit(10) - msh = MusicSessionHistory.where(:band_id => self.id).limit(10) + recordings = ClaimedRecording.joins(:recordings) + .where(:recordings => {:band_id => "#{self.id}"}) + .order('created_at DESC') + .limit(10) + + msh = MusicSessionHistory.where(:band_id => self.id) + .order('created_at DESC') + .limit(10) + recordings.concat(msh) recordings.sort! {|a,b| b.created_at <=> a.created_at}.first(5) end diff --git a/ruby/lib/jam_ruby/models/music_session_history.rb b/ruby/lib/jam_ruby/models/music_session_history.rb index 7b552c08b..3ca4c4b17 100644 --- a/ruby/lib/jam_ruby/models/music_session_history.rb +++ b/ruby/lib/jam_ruby/models/music_session_history.rb @@ -15,7 +15,7 @@ module JamRuby :foreign_key => :band_id, :inverse_of => :music_session_history) - has_many :music_session_user_history, :class_name => "JamRuby::MusicSessionUserHistory", :foreign_key => "music_session_id" + has_many :music_session_user_histories, :class_name => "JamRuby::MusicSessionUserHistory", :foreign_key => "music_session_id" has_many :comments, :class_name => "JamRuby::MusicSessionComment", :foreign_key => "music_session_id" has_many :likes, :class_name => "JamRuby::MusicSessionLiker", :foreign_key => "music_session_id" @@ -31,16 +31,22 @@ module JamRuby def tracks tracks = [] - self.music_session_user_history.each do |msuh| + binding.pry + self.music_session_user_histories.each do |msuh| user = User.find(msuh.user_id) instruments = msuh.instruments.split(SEPARATOR) instruments.each do |instrument| t = Track.new - t.user = user + binding.pry + t.musician = user + binding.pry t.instrument_id = instrument + binding.pry tracks << t + binding.pry end end + binding.pry tracks end diff --git a/ruby/lib/jam_ruby/models/recorded_track.rb b/ruby/lib/jam_ruby/models/recorded_track.rb index b67ec410d..69933a560 100644 --- a/ruby/lib/jam_ruby/models/recorded_track.rb +++ b/ruby/lib/jam_ruby/models/recorded_track.rb @@ -29,6 +29,9 @@ module JamRuby validate :validate_part_complete validate :validate_too_many_upload_failures + def musician + self.user + end def can_download?(some_user) !ClaimedRecording.find_by_user_id_and_recording_id(some_user.id, recording.id).nil? diff --git a/ruby/lib/jam_ruby/models/track.rb b/ruby/lib/jam_ruby/models/track.rb index 21f45c40f..d91f00f42 100644 --- a/ruby/lib/jam_ruby/models/track.rb +++ b/ruby/lib/jam_ruby/models/track.rb @@ -7,6 +7,8 @@ module JamRuby default_scope order('created_at ASC') + attr_accessor :musician + SOUND = %w(mono stereo) belongs_to :connection, :class_name => "JamRuby::Connection", :inverse_of => :tracks @@ -18,6 +20,14 @@ module JamRuby self.connection.user end + def musician + @musician + end + + def musician=(user) + @musician = user + end + def self.index(current_user, music_session_id) query = Track .joins( diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 17c5cfc47..cb4c0c212 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -290,8 +290,15 @@ module JamRuby end def recent_history - recordings = ClaimedRecording.joins(:recording).where(:recordings => {:owner_id => "#{self.id}"}).limit(10) - msh = MusicSessionHistory.where(:user_id => self.id).limit(10) + recordings = ClaimedRecording.joins(:recording) + .where(:recordings => {:owner_id => "#{self.id}"}) + .order('created_at DESC') + .limit(10) + + msh = MusicSessionHistory.where(:user_id => self.id) + .order('created_at DESC') + .limit(10) + recordings.concat(msh) recordings.sort! {|a,b| b.created_at <=> a.created_at}.first(5) end diff --git a/web/app/assets/stylesheets/client/screen_common.css.scss b/web/app/assets/stylesheets/client/screen_common.css.scss index 0a986912d..fe9d3497b 100644 --- a/web/app/assets/stylesheets/client/screen_common.css.scss +++ b/web/app/assets/stylesheets/client/screen_common.css.scss @@ -150,64 +150,60 @@ textarea { /* Start of Jeff's common.css file */ body { - font-family: Raleway, Arial, Helvetica, sans-serif; - font-size: 14px; - font-weight: 300; - color: #FFF; - padding:3% 6%; - background-color: #262626; - position:relative; + font-family: Raleway, Arial, Helvetica, sans-serif; + font-size: 14px; + font-weight: 300; + color: #FFF; + padding:3% 6%; + background-color: #262626; + position:relative; } h1, h2, h3, h4, h5, h6, p, div, table, form, img, tr, td, th { - margin:0; - border:0; - padding:0; + margin:0; + border:0; + padding:0; } -a { - display:inline-block; -} +a {display:inline-block;} +a img {border:none;} +.clearall {clear:both;} +.clearleft {clear:left;} +small, .small {font-size:11px;} +.bold {font-weight:bold;} -small, .small { - font-size:11px; -} - -.bold { - font-weight:bold; -} .button-grey { - margin:0px 8px 0px 8px; - background-color:#666; - border: solid 1px #868686; - outline:solid 2px #666; - padding:3px 10px; - font-family:raleway; - font-size:12px; - font-weight:300; - cursor:pointer; - color:#ccc; - text-decoration:none; + margin:0px 8px 0px 8px; + background-color:#666; + border: solid 1px #868686; + outline:solid 2px #666; + padding:3px 10px; + font-family:raleway; + font-size:12px; + font-weight:300; + cursor:pointer; + color:#ccc; + text-decoration:none; } .button-grey:hover { - background-color:#999; - color:#FFF; + background-color:#999; + color:#FFF; text-decoration:none; } .button-orange { - margin:0px 8px 0px 8px; - background-color: #ED3618; - border: solid 1px #F27861; - outline: solid 2px #ED3618; - padding:3px 10px; - font-family:raleway; - font-size:12px; - font-weight:300; - cursor:pointer; - color:#FC9; - text-decoration:none; + margin:0px 8px 0px 8px; + background-color: #ED3618; + border: solid 1px #F27861; + outline: solid 2px #ED3618; + padding:3px 10px; + font-family:raleway; + font-size:12px; + font-weight:300; + cursor:pointer; + color:#FC9; + text-decoration:none; } .smallbutton { @@ -216,8 +212,8 @@ small, .small { } .button-orange:hover { - background-color:#f16750; - color:#FFF; + background-color:#f16750; + color:#FFF; text-decoration:none; } @@ -234,17 +230,6 @@ small, .small { background-color:#666; } -a img { - border:none; -} - -.clearall { - clear:both; -} -.clearleft { - clear:left; -} - .f8 {font-size:8px !important} .f9 {font-size:9px !important} .f10 {font-size:10px !important} @@ -337,29 +322,29 @@ a img { } .op50 { - opacity: .5; - -ms-filter: "alpha(opacity=50)"; + opacity: .5; + -ms-filter: "alpha(opacity=50)"; } .op30 { - opacity: .3; - -ms-filter: "alpha(opacity=30)"; + opacity: .3; + -ms-filter: "alpha(opacity=30)"; } .nowrap { - display:inline-block; - white-space:nowrap; + display:inline-block; + white-space:nowrap; } .overlay { display:none; - position:fixed; - width:100%; - height:100%; - top:0px; - left:0px; + position:fixed; + width:100%; + height:100%; + top:0px; + left:0px; z-index: 999; - background-image:url('/assets/shared/bkg_overlay.png'); + background-image:url('/assets/shared/bkg_overlay.png'); } .overlay-small { diff --git a/web/app/assets/stylesheets/web/main.css.scss b/web/app/assets/stylesheets/web/main.css.scss index 49df23e0f..44fcf4ddb 100644 --- a/web/app/assets/stylesheets/web/main.css.scss +++ b/web/app/assets/stylesheets/web/main.css.scss @@ -58,12 +58,19 @@ body.web { padding:25px; padding-top:0px; line-height:130%; - } + + h2 { + font-size:18px !important; + line-height:normal; + color:#fff; + } + a { + text-decoration: underline !important; + } - .landing-sidebar h2 { - font-size:18px !important; - line-height:normal; - color:#fff; + em { + font-style: italic !important; + } } .landing-band { diff --git a/web/app/assets/stylesheets/web/sessions.css.scss b/web/app/assets/stylesheets/web/sessions.css.scss index 139597f9c..1e790e03a 100644 --- a/web/app/assets/stylesheets/web/sessions.css.scss +++ b/web/app/assets/stylesheets/web/sessions.css.scss @@ -1,2 +1,19 @@ +/*.session-controls { + background-color:#471f18; +} +.session-controls.inprogress { + background-color:#4C742E; +} +.session-status-ended, .session-status { + float:left; + font-size:18px; +} + +.session-status-inprogress { + float:left; + font-size:15px; + color:#cccc00; + margin-left:20px; +}*/ \ No newline at end of file diff --git a/web/app/views/music_sessions/show.html.erb b/web/app/views/music_sessions/show.html.erb index 87a9146a6..1ba28d42f 100644 --- a/web/app/views/music_sessions/show.html.erb +++ b/web/app/views/music_sessions/show.html.erb @@ -12,39 +12,43 @@ <%= @music_session.band.name %> <% else %>
- <% unless @music_session.creator.photo_url.blank? %> - <%= image_tag "#{@music_session.creator.photo_url}", {:alt => ""} %> + <% unless @music_session.user.photo_url.blank? %> + <%= image_tag "#{@music_session.user.photo_url}", {:alt => ""} %> <% else %> <%= image_tag "shared/avatar_generic.png", {:alt => ""} %> <% end %>
- <%= @music_session.creator.name %> + <%= @music_session.user.name %> <% end %>
-
SESSION: Live Session in Progress
-
<%= @cmusic_session.created_at.strftime("%b %e %Y, %l:%M %p") %>
+
SESSION
+
<%= @music_session.created_at.strftime("%b %e %Y, %l:%M %p") %>


-

<%= @music_session.name %>

+
<%= @music_session.description %>

-
TODO: Which field is this in the database??

+
<%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20} %> -
LIVE SESSION IN PROGRESS
-
1:23
+ <% if @music_session.session_removed_at.blank? %> +
SESSION IN PROGRESS
+
1:23
+ <% else %> +
LIVE SESSION ENDED
+ <% end %>
-
<%= @music_session.genres.split('|').first.id.capitalize %>
+
<%= @music_session.genres.split('|').first.capitalize %>
<%= @music_session.comment_count %> - <%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle"} %>     + <%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :style => "vertical-align:middle"} %>     <%= @music_session.like_count %> - <%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle"} %> + <%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :style => "vertical-align:middle"} %>


diff --git a/web/app/views/recordings/show.html.erb b/web/app/views/recordings/show.html.erb index a78b3e4b4..60b11a6d7 100644 --- a/web/app/views/recordings/show.html.erb +++ b/web/app/views/recordings/show.html.erb @@ -31,7 +31,7 @@ <%= image_tag "content/icon_like.png", {:width => 12, :height => 12} %> LIKE    <%= image_tag "content/icon_share.png", {:width => 13, :height => 15} %> SHARE
-
TODO: Which field is this in the database??

+
<%= @claimed_recording.description %>

<%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20} %> diff --git a/web/app/views/shared/_landing_sidebar.html.erb b/web/app/views/shared/_landing_sidebar.html.erb index 36cb3abfb..93d786fdc 100644 --- a/web/app/views/shared/_landing_sidebar.html.erb +++ b/web/app/views/shared/_landing_sidebar.html.erb @@ -1,26 +1,43 @@ -

-

More by <%= user.name %>:


-
Now:
- -
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis.
-

-
Yesterday:
-
RECORDING: You Hurt Me Bad
-
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi.
-

-
Dec. 18th:
-
SESSION: Session Ended. Unavailable.
-
Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum.
-

-
Dec. 12th:
-
RECORDING: Bustin' My Chops
-
Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros.
-

-
Dec. 10th:
-
SESSION: Session Ended. Unavailable.
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim.
-

-
Nov. 29th:
-
SESSION: Session Ended. Unavailable.
-
Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer.
+

+ +

More by <%= user.name %>:


+ + <% recent_history.each do |history_record| %> + + <% if history_record.instance_of? ClaimedRecording %> +
+ <%= history_record.created_at.strftime("%b #{history_record.created_at.day.ordinalize}") %>: +
+
+ RECORDING: + Test +
+ + <% elsif history_record.instance_of? MusicSessionHistory %> +
+ + <% if history_record.session_removed_at.blank? %> + Now: + <% else %> + <%= history_record.session_removed_at.strftime("%b #{history_record.session_removed_at.day.ordinalize}") %>: + <% end %> + +
+
+ SESSION:  + <% if history_record.session_removed_at.blank? %> + Live Session in Progress + <% else %> + Session Ended. Unavailable. + <% end %> +
+ <% end %> + +
<%= history_record.description %>
+ <% if history_record != recent_history.last %> +

+ <% end %> + + <% end %> +
\ No newline at end of file diff --git a/web/app/views/shared/_track_details.html.erb b/web/app/views/shared/_track_details.html.erb index 80bd42c68..50263187a 100644 --- a/web/app/views/shared/_track_details.html.erb +++ b/web/app/views/shared/_track_details.html.erb @@ -9,14 +9,14 @@
- <% unless track.user.photo_url.blank? %> - <%= image_tag "#{track.user.photo_url}", {:alt => ""} %> + <% unless track.musician.photo_url.blank? %> + <%= image_tag "#{track.musician.photo_url}", {:alt => ""} %> <% else %> <%= image_tag "shared/avatar_generic.png", {:alt => ""} %> <% end %>
-
<%= track.user.name %>
+
<%= track.musician.name %>
<%= image_tag "content/icon_instrument_#{track.instrument_id.tr(" ", "_")}45.png", {:width => 32, :alt => "", :title => "#{track.instrument_id}"} %> diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index aa26582a7..bd84734bb 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -48,7 +48,7 @@ SampleApp::Application.configure do config.assets.debug = false # Set the logging destination(s) - config.log_to = %w[stdout file] + # config.log_to = %w[stdout file] # Show the logging configuration on STDOUT config.show_log_configuration = true From 40a8dbd89ef3856c13d02f73e7c0c922fc8e81d3 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 26 Jan 2014 16:48:15 -0500 Subject: [PATCH 05/37] remove binding.pry --- ruby/lib/jam_ruby/models/music_session_history.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ruby/lib/jam_ruby/models/music_session_history.rb b/ruby/lib/jam_ruby/models/music_session_history.rb index 3ca4c4b17..045515d38 100644 --- a/ruby/lib/jam_ruby/models/music_session_history.rb +++ b/ruby/lib/jam_ruby/models/music_session_history.rb @@ -31,22 +31,16 @@ module JamRuby def tracks tracks = [] - binding.pry self.music_session_user_histories.each do |msuh| user = User.find(msuh.user_id) instruments = msuh.instruments.split(SEPARATOR) instruments.each do |instrument| t = Track.new - binding.pry t.musician = user - binding.pry t.instrument_id = instrument - binding.pry tracks << t - binding.pry end end - binding.pry tracks end From 374a9da9575be6b17475c5d7f4b33050375a6533 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 28 Jan 2014 02:35:35 -0500 Subject: [PATCH 06/37] VRFS-986 landing page dev complete --- .../jam_ruby/models/music_session_comment.rb | 2 +- .../jam_ruby/models/music_session_history.rb | 2 +- .../jam_ruby/models/music_session_liker.rb | 2 +- web/app/assets/javascripts/jam_rest.js | 56 +++++++++++- .../api_music_sessions_controller.rb | 13 +-- .../controllers/api_recordings_controller.rb | 19 ++-- web/app/views/music_sessions/show.html.erb | 81 ++++++++++++++--- web/app/views/recordings/show.html.erb | 88 ++++++++++++++++--- web/app/views/shared/_comments.html.erb | 2 +- web/config/environments/development.rb | 2 +- 10 files changed, 226 insertions(+), 41 deletions(-) diff --git a/ruby/lib/jam_ruby/models/music_session_comment.rb b/ruby/lib/jam_ruby/models/music_session_comment.rb index 71fa8ae9a..e9d213574 100644 --- a/ruby/lib/jam_ruby/models/music_session_comment.rb +++ b/ruby/lib/jam_ruby/models/music_session_comment.rb @@ -7,7 +7,7 @@ module JamRuby default_scope order('created_at DESC') - belongs_to :music_session, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id" + belongs_to :music_session_history, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id" belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "creator_id" end diff --git a/ruby/lib/jam_ruby/models/music_session_history.rb b/ruby/lib/jam_ruby/models/music_session_history.rb index 045515d38..0ceca19bf 100644 --- a/ruby/lib/jam_ruby/models/music_session_history.rb +++ b/ruby/lib/jam_ruby/models/music_session_history.rb @@ -3,7 +3,7 @@ module JamRuby self.table_name = "music_sessions_history" - self.primary_key = 'id' + self.primary_key = 'music_session_id' belongs_to(:user, :class_name => 'JamRuby::User', diff --git a/ruby/lib/jam_ruby/models/music_session_liker.rb b/ruby/lib/jam_ruby/models/music_session_liker.rb index a7d89fc72..16ec64372 100644 --- a/ruby/lib/jam_ruby/models/music_session_liker.rb +++ b/ruby/lib/jam_ruby/models/music_session_liker.rb @@ -5,7 +5,7 @@ module JamRuby self.primary_key = 'id' - belongs_to :music_session, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id" + belongs_to :music_session_history, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id" belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id" end diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 556512a40..c8206317c 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -35,7 +35,6 @@ } function updateSession(id, newSession, onSuccess) { - logger.debug('Rest.updateSession'); return $.ajax('/api/sessions/' + id, { type: "PUT", data : newSession, @@ -44,6 +43,56 @@ }); } + function addSessionComment(sessionId, userId, comment) { + return $.ajax({ + url: '/api/sessions/' + sessionId + "/comments", + type: "POST", + data : JSON.stringify({"comment": comment, "user_id": userId}), + dataType : 'json', + contentType: 'application/json' + }); + } + + function addSessionLike(sessionId, userId) { + return $.ajax({ + url: '/api/sessions/' + sessionId + "/likes", + type: "POST", + data : JSON.stringify({"user_id": userId}), + dataType : 'json', + contentType: 'application/json' + }); + } + + function addRecordingComment(recordingId, userId, comment) { + return $.ajax({ + url: '/api/recordings/' + recordingId + "/comments", + type: "POST", + data : JSON.stringify({"comment": comment, "user_id": userId}), + dataType : 'json', + contentType: 'application/json' + }); + } + + function addRecordingLike(recordingId, userId) { + return $.ajax({ + url: '/api/recordings/' + recordingId + "/likes", + type: "POST", + data : JSON.stringify({"user_id": userId}), + dataType : 'json', + contentType: 'application/json' + }); + } + + function addRecordingPlay(recordingId, userId) { + return $.ajax({ + url: '/api/recordings/' + recordingId + "/plays", + type: "POST", + data : JSON.stringify({"user_id": userId}), + dataType : 'json', + contentType: 'application/json' + }); + } + function getBand(bandId) { return $.ajax({ type: "GET", @@ -705,6 +754,11 @@ this.getBandFollowing = getBandFollowing; this.getBands = getBands; this.updateSession = updateSession; + this.addSessionComment = addSessionComment; + this.addSessionLike = addSessionLike; + this.addRecordingComment = addRecordingComment; + this.addRecordingLike = addRecordingLike; + this.addRecordingPlay = addRecordingPlay; this.getSession = getSession; this.getClientDownloads = getClientDownloads; this.createInvitation = createInvitation; diff --git a/web/app/controllers/api_music_sessions_controller.rb b/web/app/controllers/api_music_sessions_controller.rb index ecfd62359..cf0aad771 100644 --- a/web/app/controllers/api_music_sessions_controller.rb +++ b/web/app/controllers/api_music_sessions_controller.rb @@ -89,7 +89,6 @@ class ApiMusicSessionsController < ApiController end def participant_create - @connection = MusicSessionManager.new.participant_create( current_user, params[:id], @@ -243,14 +242,17 @@ class ApiMusicSessionsController < ApiController def add_comment if params[:id].blank? render :json => { :message => "Session ID is required" }, :status => 400 + return end if params[:user_id].blank? render :json => { :message => "User ID is required" }, :status => 400 + return end if params[:comment].blank? render :json => { :message => "Comment is required" }, :status => 400 + return end comment = MusicSessionComment.new @@ -262,18 +264,17 @@ class ApiMusicSessionsController < ApiController if comment.errors.any? render :json => { :message => "Unexpected error occurred" }, :status => 500 + return else render :json => {}, :status => 201 + return end end def add_like if params[:id].blank? render :json => { :message => "Session ID is required" }, :status => 400 - end - - if params[:user_id].blank? - render :json => { :message => "User ID is required" }, :status => 400 + return end liker = MusicSessionLiker.new @@ -284,8 +285,10 @@ class ApiMusicSessionsController < ApiController if liker.errors.any? render :json => { :message => "Unexpected error occurred" }, :status => 500 + return else render :json => {}, :status => 201 + return end end diff --git a/web/app/controllers/api_recordings_controller.rb b/web/app/controllers/api_recordings_controller.rb index ce06547c6..1947b7baa 100644 --- a/web/app/controllers/api_recordings_controller.rb +++ b/web/app/controllers/api_recordings_controller.rb @@ -83,14 +83,17 @@ class ApiRecordingsController < ApiController def add_comment if params[:id].blank? render :json => { :message => "Recording ID is required" }, :status => 400 + return end if params[:user_id].blank? render :json => { :message => "User ID is required" }, :status => 400 + return end if params[:comment].blank? render :json => { :message => "Comment is required" }, :status => 400 + return end comment = RecordingComment.new @@ -102,18 +105,17 @@ class ApiRecordingsController < ApiController if comment.errors.any? render :json => { :message => "Unexpected error occurred" }, :status => 500 + return else render :json => {}, :status => 201 + return end end def add_like if params[:id].blank? render :json => { :message => "Recording ID is required" }, :status => 400 - end - - if params[:user_id].blank? - render :json => { :message => "User ID is required" }, :status => 400 + return end liker = RecordingLiker.new @@ -124,18 +126,17 @@ class ApiRecordingsController < ApiController if liker.errors.any? render :json => { :message => "Unexpected error occurred" }, :status => 500 + return else render :json => {}, :status => 201 + return end end def add_play if params[:id].blank? render :json => { :message => "Recording ID is required" }, :status => 400 - end - - if params[:user_id].blank? - render :json => { :message => "User ID is required" }, :status => 400 + return end play = RecordingPlay.new @@ -146,8 +147,10 @@ class ApiRecordingsController < ApiController if play.errors.any? render :json => { :message => "Unexpected error occurred" }, :status => 500 + return else render :json => {}, :status => 201 + return end end diff --git a/web/app/views/music_sessions/show.html.erb b/web/app/views/music_sessions/show.html.erb index 1ba28d42f..2bad9aa50 100644 --- a/web/app/views/music_sessions/show.html.erb +++ b/web/app/views/music_sessions/show.html.erb @@ -27,14 +27,16 @@
<%= @music_session.created_at.strftime("%b %e %Y, %l:%M %p") %>


<%= @music_session.description %>

- + <% if @music_session.session_removed_at.blank? %> + + <% end %>
- <%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20} %> + <%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20, :alt => ""} %> <% if @music_session.session_removed_at.blank? %>
SESSION IN PROGRESS
1:23
@@ -45,10 +47,13 @@
<%= @music_session.genres.split('|').first.capitalize %>
- <%= @music_session.comment_count %> - <%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :style => "vertical-align:middle"} %>     - <%= @music_session.like_count %> - <%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :style => "vertical-align:middle"} %> + + <%= @music_session.comment_count %> + <%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :style => "vertical-align:middle", :alt => ""} %>     + + <%= @music_session.like_count %> + <%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :style => "vertical-align:middle", :alt => ""} %> +


@@ -68,9 +73,65 @@ <% content_for :after_black_bar do %>
- <%= render :partial => "shared/comments", :locals => {:comments => @music_session.comments} %> + <%= render :partial => "shared/comments", :locals => {:comments => @music_session.comments, :id => "txtSessionComment"} %> <% end %> <%= javascript_include_tag "web/sessions" %> <%= render "clients/shareDialog" %> + + diff --git a/web/app/views/recordings/show.html.erb b/web/app/views/recordings/show.html.erb index 60b11a6d7..0bdb1e444 100644 --- a/web/app/views/recordings/show.html.erb +++ b/web/app/views/recordings/show.html.erb @@ -28,17 +28,17 @@

<%= @claimed_recording.name %>


<%= @claimed_recording.description %>

- <%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20} %> + <%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20, :alt => ""} %>
0:00
-
<%= image_tag "content/slider_playcontrols.png", {:width => 5, :height => 16} %>
+
<%= image_tag "content/slider_playcontrols.png", {:width => 5, :height => 16, :alt => ""} %>
4:59
@@ -47,12 +47,12 @@
<%= @claimed_recording.genre_id.capitalize %>
- <%= @claimed_recording.recording.play_count %> - <%= image_tag "content/icon_arrow.png", {:width => 7, :height => 12, :align => "absmiddle"} %>     - <%= @claimed_recording.recording.comment_count %> - <%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle"} %>     - <%= @claimed_recording.recording.like_count %> - <%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle"} %> + <%= @claimed_recording.recording.play_count %> + <%= image_tag "content/icon_arrow.png", {:width => 7, :height => 12, :align => "absmiddle", :alt => ""} %>     + <%= @claimed_recording.recording.comment_count %> + <%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :alt => ""} %>     + <%= @claimed_recording.recording.like_count %> + <%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :alt => ""} %>


@@ -72,9 +72,73 @@ <% content_for :after_black_bar do %>
- <%= render :partial => "shared/comments", :locals => {:comments => @claimed_recording.recording.comments} %> + <%= render :partial => "shared/comments", :locals => {:comments => @claimed_recording.recording.comments, :id => "txtRecordingComment"} %> <% end %> <%= javascript_include_tag "web/recordings" %> -<%= render "clients/shareDialog" %> \ No newline at end of file +<%= render "clients/shareDialog" %> + + diff --git a/web/app/views/shared/_comments.html.erb b/web/app/views/shared/_comments.html.erb index 955d8baae..1094e747e 100644 --- a/web/app/views/shared/_comments.html.erb +++ b/web/app/views/shared/_comments.html.erb @@ -4,7 +4,7 @@ <%= image_tag "shared/avatar_generic.png", {:alt => ""} %>
- +

diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index bd84734bb..aa26582a7 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -48,7 +48,7 @@ SampleApp::Application.configure do config.assets.debug = false # Set the logging destination(s) - # config.log_to = %w[stdout file] + config.log_to = %w[stdout file] # Show the logging configuration on STDOUT config.show_log_configuration = true From 3ad56b41426f355377193502d344e67aec5d48e2 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 28 Jan 2014 10:30:16 -0500 Subject: [PATCH 07/37] fix session bug --- ruby/lib/jam_ruby/models/music_session_comment.rb | 9 +++++++-- ruby/lib/jam_ruby/models/music_session_history.rb | 13 ++++++++++++- ruby/lib/jam_ruby/models/music_session_liker.rb | 9 +++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ruby/lib/jam_ruby/models/music_session_comment.rb b/ruby/lib/jam_ruby/models/music_session_comment.rb index e9d213574..5771bdc30 100644 --- a/ruby/lib/jam_ruby/models/music_session_comment.rb +++ b/ruby/lib/jam_ruby/models/music_session_comment.rb @@ -7,8 +7,13 @@ module JamRuby default_scope order('created_at DESC') - belongs_to :music_session_history, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id" - belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "creator_id" + belongs_to(:music_session_history, + :class_name => "JamRuby::MusicSessionHistory", + :foreign_key => "music_session_id") + + belongs_to(:user, + :class_name => "JamRuby::User", + :foreign_key => "creator_id") end end \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/music_session_history.rb b/ruby/lib/jam_ruby/models/music_session_history.rb index 0ceca19bf..d1b41016a 100644 --- a/ruby/lib/jam_ruby/models/music_session_history.rb +++ b/ruby/lib/jam_ruby/models/music_session_history.rb @@ -3,7 +3,7 @@ module JamRuby self.table_name = "music_sessions_history" - self.primary_key = 'music_session_id' + self.primary_key = 'id' belongs_to(:user, :class_name => 'JamRuby::User', @@ -130,5 +130,16 @@ module JamRuby .order('created_at DESC') end + def comments + @comments ||= JamRuby::MusicSessionComment + .where(:music_session_id => self.music_session_id) + .order('created_at DESC') + end + + def likes + @likes ||= JamRuby::MusicSessionLiker + .where(:music_session_id => self.music_session_id) + end + end end diff --git a/ruby/lib/jam_ruby/models/music_session_liker.rb b/ruby/lib/jam_ruby/models/music_session_liker.rb index 16ec64372..9b4cb69df 100644 --- a/ruby/lib/jam_ruby/models/music_session_liker.rb +++ b/ruby/lib/jam_ruby/models/music_session_liker.rb @@ -5,8 +5,13 @@ module JamRuby self.primary_key = 'id' - belongs_to :music_session_history, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id" - belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id" + belongs_to(:music_session_history, + :class_name => "JamRuby::MusicSessionHistory", + :foreign_key => "music_session_id") + + belongs_to(:user, + :class_name => "JamRuby::User", + :foreign_key => "liker_id") end end \ No newline at end of file From 555b53e3c372488acdeadbc5c2d7fdb3966fc2fc Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 28 Jan 2014 10:31:57 -0500 Subject: [PATCH 08/37] format code --- ruby/lib/jam_ruby/models/music_session_comment.rb | 8 ++++---- ruby/lib/jam_ruby/models/music_session_liker.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ruby/lib/jam_ruby/models/music_session_comment.rb b/ruby/lib/jam_ruby/models/music_session_comment.rb index 5771bdc30..b23383b33 100644 --- a/ruby/lib/jam_ruby/models/music_session_comment.rb +++ b/ruby/lib/jam_ruby/models/music_session_comment.rb @@ -8,12 +8,12 @@ module JamRuby default_scope order('created_at DESC') belongs_to(:music_session_history, - :class_name => "JamRuby::MusicSessionHistory", - :foreign_key => "music_session_id") + :class_name => "JamRuby::MusicSessionHistory", + :foreign_key => "music_session_id") belongs_to(:user, - :class_name => "JamRuby::User", - :foreign_key => "creator_id") + :class_name => "JamRuby::User", + :foreign_key => "creator_id") end end \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/music_session_liker.rb b/ruby/lib/jam_ruby/models/music_session_liker.rb index 9b4cb69df..538822c6e 100644 --- a/ruby/lib/jam_ruby/models/music_session_liker.rb +++ b/ruby/lib/jam_ruby/models/music_session_liker.rb @@ -6,12 +6,12 @@ module JamRuby self.primary_key = 'id' belongs_to(:music_session_history, - :class_name => "JamRuby::MusicSessionHistory", - :foreign_key => "music_session_id") + :class_name => "JamRuby::MusicSessionHistory", + :foreign_key => "music_session_id") belongs_to(:user, - :class_name => "JamRuby::User", - :foreign_key => "liker_id") + :class_name => "JamRuby::User", + :foreign_key => "liker_id") end end \ No newline at end of file From 38a8ca08bcdc7b870fd0536fd5d37430f3bce1d5 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 29 Jan 2014 10:59:14 -0600 Subject: [PATCH 09/37] * renabling logging --- web/config/environments/development.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index bd84734bb..aa26582a7 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -48,7 +48,7 @@ SampleApp::Application.configure do config.assets.debug = false # Set the logging destination(s) - # config.log_to = %w[stdout file] + config.log_to = %w[stdout file] # Show the logging configuration on STDOUT config.show_log_configuration = true From 873037101c41ffc2d5d34383d4f9713dfb58dd0e Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 29 Jan 2014 11:04:42 -0600 Subject: [PATCH 10/37] * removing errant m VRFS-1027 --- web/app/views/clients/_profile.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/views/clients/_profile.html.erb b/web/app/views/clients/_profile.html.erb index 50828ba03..ca54d4010 100644 --- a/web/app/views/clients/_profile.html.erb +++ b/web/app/views/clients/_profile.html.erb @@ -1,4 +1,4 @@ -m +
From 3d453468f28966e15e10a19989087d3d6f92ca62 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 29 Jan 2014 13:24:34 -0600 Subject: [PATCH 11/37] * adding ability to run everything within jam-web for jobs --- .../resque/scheduled/icecast_source_check.rb | 3 --- web/config/initializers/resque.rb | 14 +++++++++++++- web/config/routes.rb | 9 +++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb b/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb index d832f4d2d..d17320cb4 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb @@ -11,13 +11,10 @@ module JamRuby class IcecastSourceCheck extend Resque::Plugins::LonelyJob - @queue = :icecast_source_check - @@log = Logging.logger[IcecastSourceCheck] - def self.perform @@log.debug("waking up") diff --git a/web/config/initializers/resque.rb b/web/config/initializers/resque.rb index 5c3c402fc..5077fea0f 100644 --- a/web/config/initializers/resque.rb +++ b/web/config/initializers/resque.rb @@ -1 +1,13 @@ -Resque.redis = Rails.application.config.redis_host \ No newline at end of file +Resque.redis = Rails.application.config.redis_host + + +if !$rails_rake_task && Rails.env == 'development' && ENV['RUN_JOBS_INLINE'] == '1' + + Thread.new do + system('INTERVAL=1 bundle exec rake all_jobs') + end + + Thread.new do + system('bundle exec rake scheduler') + end +end \ No newline at end of file diff --git a/web/config/routes.rb b/web/config/routes.rb index dc7a1cfcd..1a77090a3 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -71,6 +71,14 @@ SampleApp::Application.routes.draw do # email update match '/confirm_email' => 'users#finalize_update_email', :as => 'confirm_email' # NOTE: if you change this, you break outstanding email changes because links in user inboxes are broken + # embed resque-web if this is development mode + if Rails.env == "development" + require 'resque/server' + require 'resque-retry' + require 'resque-retry/server' + mount Resque::Server.new, :at => "/resque" if Rails.env == "development" + end + scope '/corp' do match '/about', to: 'corps#about', as: 'corp_about' match '/contact', to: 'corps#contact', as: 'corp_contact' @@ -324,4 +332,5 @@ SampleApp::Application.routes.draw do match '/icecast/listener_add' => 'api_icecast#listener_add', :via => :post match '/icecast/listener_remove' => 'api_icecast#listener_remove', :via => :post end + end From 55850ae602edb28b045d6c098edf8dc18cf535d4 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 29 Jan 2014 13:26:11 -0600 Subject: [PATCH 12/37] * adding ability to run everything within jam-web for jobs --- runadmin | 6 ++++++ runjobs | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100755 runadmin create mode 100755 runjobs diff --git a/runadmin b/runadmin new file mode 100755 index 000000000..648a2a9ac --- /dev/null +++ b/runadmin @@ -0,0 +1,6 @@ +#!/bin/bash + +pushd admin +# run jam-admin rails server +bundle exec rails s +popd diff --git a/runjobs b/runjobs new file mode 100755 index 000000000..babe280ff --- /dev/null +++ b/runjobs @@ -0,0 +1,6 @@ +#!/bin/bash + +pushd web +# run all_jobs rake task; this waits on new jobs from the resque queue, i.e., audiomixer, icecast, etc +bundle exec rake all_jobs +popd From 3903822ca5912f86227c8bcd55b74cb6188a5521 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 29 Jan 2014 14:33:47 -0600 Subject: [PATCH 13/37] * overriding lock timeout for LonelyJobs --- .../jam_ruby/resque/icecast_config_writer.rb | 5 +++ .../resque/scheduled/IcecastSourceCheck.rb | 32 ------------------- .../resque/scheduled/audiomixer_retry.rb | 6 ++++ .../resque/scheduled/icecast_config_retry.rb | 6 ++++ .../resque/scheduled/icecast_source_check.rb | 6 ++++ 5 files changed, 23 insertions(+), 32 deletions(-) delete mode 100644 ruby/lib/jam_ruby/resque/scheduled/IcecastSourceCheck.rb diff --git a/ruby/lib/jam_ruby/resque/icecast_config_writer.rb b/ruby/lib/jam_ruby/resque/icecast_config_writer.rb index bbecffa29..a02761e7b 100644 --- a/ruby/lib/jam_ruby/resque/icecast_config_writer.rb +++ b/ruby/lib/jam_ruby/resque/icecast_config_writer.rb @@ -30,6 +30,11 @@ module JamRuby "icecast-#{server_id}" end + def self.lock_timeout + # this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job + 60 + end + def self.perform(icecast_server_id) icecast = IcecastConfigWriter.new() icecast.icecast_server_id = icecast_server_id diff --git a/ruby/lib/jam_ruby/resque/scheduled/IcecastSourceCheck.rb b/ruby/lib/jam_ruby/resque/scheduled/IcecastSourceCheck.rb deleted file mode 100644 index 4d1577637..000000000 --- a/ruby/lib/jam_ruby/resque/scheduled/IcecastSourceCheck.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'json' -require 'resque' -require 'resque-retry' -require 'net/http' -require 'digest/md5' - -module JamRuby - - # http://blog.bignerdranch.com/1643-never-use-resque-for-serial-jobs/ - # periodically scheduled to find sources that need to be brought down, or alternatively, it seems the client failed to start sourcing - class IcecastSourceCheck - - @queue = :icecast_source_check - - @@log = Logging.logger[IcecastSourceCheck] - - def self.perform - @@log.debug("waking up") - - # if we haven't seen updated_at be tickled in 5 minutes, but config_changed is still set to TRUE, this record has gotten stale - IcecastMount.find_each(:conditions => "sourced_needs_changing_at < (NOW() - interval '#{APP_CONFIG.icecast_max_sourced_changed} second')", :batch_size => 100) do |server| - server.with_lock do - IcecastConfigWriter.enqueue(server.server_id) - end - - end - - @@log.debug("done") - end - end - -end \ No newline at end of file diff --git a/ruby/lib/jam_ruby/resque/scheduled/audiomixer_retry.rb b/ruby/lib/jam_ruby/resque/scheduled/audiomixer_retry.rb index 34e7571cb..7b9b338c9 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/audiomixer_retry.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/audiomixer_retry.rb @@ -8,11 +8,17 @@ module JamRuby # periodically scheduled to find jobs that need retrying class AudioMixerRetry + extend Resque::Plugins::LonelyJob @queue = :audiomixer_retry @@log = Logging.logger[AudioMixerRetry] + def self.lock_timeout + # this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job + 120 + end + def self.perform AudioMixer.queue_jobs_needing_retry end diff --git a/ruby/lib/jam_ruby/resque/scheduled/icecast_config_retry.rb b/ruby/lib/jam_ruby/resque/scheduled/icecast_config_retry.rb index 340e9a05f..cbc7c6209 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/icecast_config_retry.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/icecast_config_retry.rb @@ -8,11 +8,17 @@ module JamRuby # periodically scheduled to find jobs that need retrying class IcecastConfigRetry + extend Resque::Plugins::LonelyJob @queue = :icecast_config_retry @@log = Logging.logger[IcecastConfigRetry] + def self.lock_timeout + # this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job + 120 + end + def self.perform @@log.debug("waking up") diff --git a/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb b/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb index d17320cb4..236c6814e 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/icecast_source_check.rb @@ -15,6 +15,11 @@ module JamRuby @@log = Logging.logger[IcecastSourceCheck] + def self.lock_timeout + # this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job + 120 + end + def self.perform @@log.debug("waking up") @@ -25,6 +30,7 @@ module JamRuby @@log.debug("done") end + def run # if we haven't seen updated_at be tickled in 5 minutes, but config_changed is still set to TRUE, this record has gotten stale IcecastMount.find_each(lock: true, :conditions => "sourced_needs_changing_at < (NOW() - interval '#{APP_CONFIG.icecast_max_sourced_changed} second')", :batch_size => 100) do |mount| if mount.music_session_id From 7c39c3cd4c3364a2ccaca26427ddd525087acbb2 Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Wed, 29 Jan 2014 19:55:16 -0600 Subject: [PATCH 14/37] vrfs152: integration fb login into view code --- .../assets/javascripts/invitationDialog.js | 138 ++++--- web/app/assets/javascripts/sidebar.js | 5 + web/app/views/clients/_createSession.html.erb | 4 +- web/app/views/clients/_sidebar.html.erb | 362 +++++++++--------- web/app/views/clients/index.html.erb | 3 +- 5 files changed, 287 insertions(+), 225 deletions(-) diff --git a/web/app/assets/javascripts/invitationDialog.js b/web/app/assets/javascripts/invitationDialog.js index a3c569f59..bd25de876 100644 --- a/web/app/assets/javascripts/invitationDialog.js +++ b/web/app/assets/javascripts/invitationDialog.js @@ -1,5 +1,4 @@ (function(context,$) { - "use strict"; context.JK = context.JK || {}; context.JK.InvitationDialog = function(app) { @@ -152,49 +151,99 @@ }; window._oauth_win = window.open("/auth/google_login", "_blank", "height=500,width=500,menubar=no,resizable=no,status=no"); } + + ////////////// + // FB handlers - function showFacebookDialog() { - /* - $('#invitation-textarea-container').hide(); - $('#invitation-checkbox-container').show(); - $('#btn-send-invitation').hide(); - $('#btn-next-invitation').show(); - invitationDialog.showDialog(); - $('#invitation-checkboxes').html('
Loading your contacts...
'); - */ - window._oauth_callback = function() { - window._oauth_win.close(); - window._oauth_win = null; - window._oauth_callback = null; - /* - $.ajax({ - type: "GET", - url: "/gmail_contacts", - success: function(response) { - $('#invitation-checkboxes').html(''); - for (var i in response) { - $('#invitation-checkboxes').append(""); - } - - $('.invitation-checkbox').change(function() { - var checkedBoxes = $('.invitation-checkbox:checkbox:checked'); - var emails = ''; - for (var i = 0; i < checkedBoxes.length; i++) { - emails += $(checkedBoxes[i]).data('email') + ', '; - } - emails = emails.replace(/, $/, ''); - $('#txt-emails').val(emails); - }); - }, - error: function() { - $('#invitation-checkboxes').html("Load failed"); - } - }); - */ - }; - window._oauth_win = window.open("/auth/facebook_login", "_blank", "height=500,width=500,menubar=no,resizable=no,status=no"); + // Additional initialization code such as adding Event Listeners goes here + function handle_fblogin_response(response) { + if (response.status === 'connected') { + // the user is logged in and has authenticated your + // app, and response.authResponse supplies + // the user's ID, a valid access token, a signed + // request, and the time the access token + // and signed request each expire + var uid = response.authResponse.userID; + var accessToken = response.authResponse.accessToken; + window.fb_logged_in_state = "connected"; + } else if (response.status === 'not_authorized') { + // the user is logged in to Facebook, + // but has not authenticated your app + // TODO: popup authorization dialog + window.fb_logged_in_state = "not_authorized"; + } + else { + // the user isn't logged in to Facebook. + window.fb_logged_in_state = "not_logged_in"; + } } + this.fb_login = function() { + //try {} + FB.login(function(response) { + handle_fblogin_response(response); + }, {scope:'publish_stream'}); + } + + function show_feed_dialog() { + var obj = { + method: 'feed', + redirect_uri: 'http://jamkazamdev.local:3000/', + link: 'https://developers.facebook.com/docs/reference/dialogs/', + picture: 'http://fbrell.com/f8.jpg', + name: 'Facebook Dialogs', + caption: 'Reference Documentation', + description: 'Using Dialogs to interact with users.' + }; + function fbFeedDialogCallback(response) { + console.log("feedback dialog closed: " + response['post_id']) + } + FB.ui(obj, fbFeedDialogCallback); + } + + function showFacebookDialog(evt) { + evt.stopPropagation(); + var fb_state = window.fb_logged_in_state; + + if (fb_state == "connected") { + show_feed_dialog(); + } else if (fb_state == "not_authorized") { + this.fb_login(); + } else { + this.fb_login(); + } + } + + function callFB(fbAppID){ + var fbAppID_ = fbAppID; + window.fbAsyncInit = function() { + FB.init({ + appId : fbAppID_, + // channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', + status : true, // check the login status upon init? + cookie : true, // set sessions cookies to allow server to access the session? + xfbml : true, // parse XFBML tags on this page? + oauth : true, // enable OAuth 2.0 + }); + // listen to see if the user is known/logged in + FB.getLoginStatus(function(response) { + handle_fblogin_response(response); + }); + }; + + // Load the SDK Asynchronously + (function(d){ + var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} + js = d.createElement('script'); js.id = id; js.async = true; + js.src = "//connect.facebook.net/en_US/all.js"; + d.getElementsByTagName('head')[0].appendChild(js); + }(document)); + } + + // END FB handlers + ////////////// + + function clearTextFields() { $('#txt-emails').val('').removeData('google_invite_count'); $('#txt-message').val(''); @@ -211,16 +260,17 @@ registerEvents(false); } - function initialize(){ + function initialize(fbAppID){ var dialogBindings = { 'beforeShow' : beforeShow, 'afterHide': afterHide }; app.bindDialog('inviteUsers', dialogBindings); + + callFB(fbAppID); }; - this.initialize = initialize; this.showEmailDialog = showEmailDialog; this.showGoogleDialog = showGoogleDialog; @@ -228,4 +278,4 @@ } return this; -})(window,jQuery); \ No newline at end of file +})(window,jQuery); diff --git a/web/app/assets/javascripts/sidebar.js b/web/app/assets/javascripts/sidebar.js index 4e63c8c24..8277145c9 100644 --- a/web/app/assets/javascripts/sidebar.js +++ b/web/app/assets/javascripts/sidebar.js @@ -522,6 +522,11 @@ invitationDialog.showGoogleDialog(); return false; }); + + $('#sidebar-div .btn-facebook-invitation').click(function(evt) { + invitationDialog.showFacebookDialog(evt); + return false; + }); } function registerFriendUpdate() { diff --git a/web/app/views/clients/_createSession.html.erb b/web/app/views/clients/_createSession.html.erb index 7a0b3f565..c37a4af3e 100644 --- a/web/app/views/clients/_createSession.html.erb +++ b/web/app/views/clients/_createSession.html.erb @@ -98,16 +98,14 @@
E-mail
- -