VRFS-1942 tuning admin view
This commit is contained in:
parent
d28a65c5ff
commit
e87ae50dfe
|
|
@ -23,7 +23,7 @@ ActiveAdmin.register JamRuby::EmailBatchScheduledSessions, :as => 'Daily Session
|
|||
show :title => "Daily Session Snapshot" do |obj|
|
||||
h3 "Session created range: (#{obj.earliest_session_create_time}, #{obj.latest_session_create_time}); Earliest session start: #{obj.earliest_session_start_time}"
|
||||
h3 "Max Latency Score: #{params[:max_score] ? params[:max_score] : Score::MAX_YELLOW_LATENCY}"
|
||||
h4 "(append URL with ?max_score=NN to change max latency from default (#{Score::MAX_YELLOW_LATENCY}))"
|
||||
h4 "(append URL with ?max_score=N to change max latency from default (#{Score::MAX_YELLOW_LATENCY}))"
|
||||
|
||||
num, objs = obj.snapshot_scored_recipients
|
||||
panel "Session & Scoring Matches (#{num})" do
|
||||
|
|
@ -71,6 +71,7 @@ ActiveAdmin.register JamRuby::EmailBatchScheduledSessions, :as => 'Daily Session
|
|||
else
|
||||
ENV[EmailBatchScheduledSessions::ENV_MAX_LATENCY] = '0'
|
||||
end
|
||||
ENV[EmailBatchScheduledSessions::ENV_QUERY_LIMIT] = EmailBatchScheduledSessions::SNAPSHOT_QUERY_LIMIT
|
||||
set_resource_ivar(EmailBatchScheduledSessions.refresh_snapshot!)
|
||||
render active_admin_template('show')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ module JamRuby
|
|||
TMP_MATCH = 'tmp_matches'
|
||||
|
||||
ENV_MAX_LATENCY = 'env_max_latency'
|
||||
ENV_QUERY_LIMIT = 'env_query_limit'
|
||||
SNAPSHOT_QUERY_LIMIT = '500'
|
||||
|
||||
def self.refresh_snapshot!
|
||||
self.where(:aasm_state => 'snapshot').limit(1).first.try(:destroy)
|
||||
|
|
@ -125,6 +127,7 @@ module JamRuby
|
|||
# inserts eligible sessions to temp table
|
||||
def _collect_eligible_sessions
|
||||
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS #{TMP_SESS}")
|
||||
limit_sql = (self.snapshot? && 0 < ENV[ENV_QUERY_LIMIT].to_i) ? "LIMIT #{ENV[ENV_QUERY_LIMIT]}" : ''
|
||||
sql =<<SQL
|
||||
SELECT
|
||||
msess.id AS session_id,
|
||||
|
|
@ -144,12 +147,14 @@ WHERE
|
|||
msess.created_at < '#{latest_session_create_time}' AND
|
||||
scheduled_start >= '#{earliest_session_start_time}' AND
|
||||
(rrrs.rsvp_slot_id IS NULL OR rrrs.chosen != 't')
|
||||
#{limit_sql}
|
||||
SQL
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
end
|
||||
|
||||
def _collect_eligible_recipients
|
||||
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS #{TMP_RECIP}")
|
||||
limit_sql = (self.snapshot? && 0 < ENV[ENV_QUERY_LIMIT].to_i) ? "LIMIT #{ENV[ENV_QUERY_LIMIT]}" : ''
|
||||
# load eligible recipients into tmp table
|
||||
sql =<<SQL
|
||||
SELECT
|
||||
|
|
@ -164,15 +169,17 @@ WHERE
|
|||
users.last_jam_locidispid IS NOT NULL AND
|
||||
users.musician = 't' AND
|
||||
users.subscribe_email = 't'
|
||||
#{limit_sql}
|
||||
SQL
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
end
|
||||
|
||||
def _collect_scored_recipients
|
||||
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS #{TMP_MATCH}")
|
||||
if 0 == (max_score = ENV[ENV_MAX_LATENCY].to_i)
|
||||
if !self.snapshot? || 0 == (max_score = ENV[ENV_MAX_LATENCY].to_i)
|
||||
max_score = Score::MAX_YELLOW_LATENCY
|
||||
end
|
||||
limit_sql = (self.snapshot? && 0 < ENV[ENV_QUERY_LIMIT].to_i) ? "LIMIT #{ENV[ENV_QUERY_LIMIT]}" : ''
|
||||
sql =<<SQL
|
||||
SELECT
|
||||
DISTINCT #{TMP_RECIP}.receiver_id,
|
||||
|
|
@ -189,6 +196,7 @@ GROUP BY
|
|||
#{TMP_RECIP}.receiver_id,
|
||||
#{TMP_SESS}.session_id,
|
||||
latency
|
||||
#{limit_sql}
|
||||
SQL
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue