From c595d8158e5e3c5171e650d0767a3012ca521f46 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sat, 22 Aug 2020 09:30:20 -0500 Subject: [PATCH] better session ratings and prep for AKS test --- db/up/find_sessions_2020.sql | 2 ++ ruby/lib/jam_ruby/models/ars.rb | 3 +++ web/app/controllers/api_music_sessions_controller.rb | 7 ++++--- websocket-gateway/lib/jam_websockets/router.rb | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/db/up/find_sessions_2020.sql b/db/up/find_sessions_2020.sql index 646660cd7..09f72972e 100644 --- a/db/up/find_sessions_2020.sql +++ b/db/up/find_sessions_2020.sql @@ -52,3 +52,5 @@ ALTER TABLE arses ADD COLUMN port int default 3478; ALTER TABLE generic_state ADD COLUMN top_message VARCHAR(100000); +ALTER TABLE users ADD COLUMN beta BOOLEAN default FALSE; +ALTER TABLE arses ADD COLUMN beta BOOLEAN default FALSE; \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/ars.rb b/ruby/lib/jam_ruby/models/ars.rb index cfb054805..cd8041f10 100644 --- a/ruby/lib/jam_ruby/models/ars.rb +++ b/ruby/lib/jam_ruby/models/ars.rb @@ -7,5 +7,8 @@ module JamRuby self.table_name = "arses" @@log = Logging.logger[Ars] + def active_arses(user) + Ars.where(active: true, beta: user.beta).where('ip is not NULL').where("ip != ''").all + end end end \ No newline at end of file diff --git a/web/app/controllers/api_music_sessions_controller.rb b/web/app/controllers/api_music_sessions_controller.rb index 95999c8c6..2a52877d5 100644 --- a/web/app/controllers/api_music_sessions_controller.rb +++ b/web/app/controllers/api_music_sessions_controller.rb @@ -395,10 +395,11 @@ class ApiMusicSessionsController < ApiController session_type = "Session" end - - subject = "#{current_user.name} Rated Their #{session_type}!" + rating_type = rating > 0 ? "Good" : "Bad" + with_comment = (comment.nil? || comment.strip.empty?) ? '' : ' - With Comment' + subject = "#{current_user.name} Rated Their #{session_type} #{rating_type}#{with_comment}!" body = "Session Type: #{session_type}\n" - body << "Session Rating: #{ rating > 0 ? "Good" : "Bad"}\n" + body << "Session Rating: #{rating_type}\n" body << "Session Rating Arg: #{rating_val}\n" body << "User: #{current_user.email}\n" body << "Music Session URL: #{session_link}\n" diff --git a/websocket-gateway/lib/jam_websockets/router.rb b/websocket-gateway/lib/jam_websockets/router.rb index 1ab5e5e0c..ba7ec2e94 100644 --- a/websocket-gateway/lib/jam_websockets/router.rb +++ b/websocket-gateway/lib/jam_websockets/router.rb @@ -1355,7 +1355,7 @@ module JamWebsockets # it's possible that a client will not be represented in the database anymore, due to hard to trace/guess scenario # usually involve reconnects. Double-check that all clients in memory are actually in the database. if not, delete them from memory - @stored_ars = Ars.where(active: true).where('ip is not NULL').where("ip != ''").all + @stored_ars = Ars.active_arses(user) if @client_lookup.length == 0 return @@ -1403,7 +1403,7 @@ module JamWebsockets end cleanup_clients_with_ids(clients) end - + def periodical_stats_dump # assume 60 seconds per status dump