From b2de2a44189245a94e7362ed4594ae564952b98e Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 25 Jul 2024 14:22:54 -0400 Subject: [PATCH 1/3] Adjusting the query for conflict count speeds up the session load by at least a factor of 2 --- app/models/session.rb | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/app/models/session.rb b/app/models/session.rb index 1b858dca5..9bf026157 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -218,32 +218,20 @@ def keep_interest_trail end def self.conflict_counts - sessions = Session.arel_table conflicts = Conflicts::SessionConflict.arel_table ignored_conflicts = ::IgnoredConflict.arel_table - sessions.project( - sessions[:id].as('session_id'), + conflicts.project( + conflicts[:session_id].as('session_id'), conflicts[:session_id].count.as('conflict_count') ) - .join(conflicts, Arel::Nodes::OuterJoin) - .on( - sessions[:id].eq(conflicts[:session_id]) - .or( - sessions[:id].eq(conflicts[:conflict_session_id]) - .and( - conflicts[:conflict_type].not_eq('room_conflict') - .or( - conflicts[:conflict_type].eq('room_conflict') - .and( - conflicts[:session_start_time].not_eq(conflicts[:conflict_session_start_time]) - ) + .where( + conflicts[:conflict_type].not_eq('room_conflict') + .or( + conflicts[:conflict_type].eq('room_conflict') + .and( + conflicts[:session_start_time].not_eq(conflicts[:conflict_session_start_time]) ) - # .and( - # conflicts[:conflict_type].not_eq('person_schedule_conflict') - # .and(conflicts[:conflict_type].not_eq('person_back_to_back')) - # ) - ) ) .and( conflicts[:session_assignment_name].eq(nil).or(conflicts[:session_assignment_name].in(['Moderator', 'Participant', 'Invisible'])).and( @@ -255,7 +243,7 @@ def self.conflict_counts ) ) ) - .group('sessions.id') + .group('session_conflicts.session_id') end def schedule_consistency From f1454eb9f579d3535fac52538672d3ec6c01ad87 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 25 Jul 2024 14:34:04 -0400 Subject: [PATCH 2/3] fix join --- app/controllers/sessions_controller.rb | 3 ++- app/serializers/session_serializer.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d42169971..aa10479fe 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -287,7 +287,8 @@ def join_tables conflict_counts, sessions.create_on( conflict_counts[:session_id].eq(sessions[:id]) - ) + ), + Arel::Nodes::OuterJoin ), sessions.create_join( published_sessions, diff --git a/app/serializers/session_serializer.rb b/app/serializers/session_serializer.rb index 47fe3667c..703e18c16 100644 --- a/app/serializers/session_serializer.rb +++ b/app/serializers/session_serializer.rb @@ -123,7 +123,7 @@ class SessionSerializer attribute :has_conflicts do |session| if session.has_attribute?(:conflict_count) - session.conflict_count > 0 + session.conflict_count && session.conflict_count > 0 else (session.session_conflicts.count > 0) || (session.conflict_sessions.count > 0) end From 8e23bec7456ee84981f07ce5f798fa609eb397f1 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 25 Jul 2024 14:49:49 -0400 Subject: [PATCH 3/3] For mobile back to pink --- app/javascript/stylesheets/style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/stylesheets/style.scss b/app/javascript/stylesheets/style.scss index 7dae39655..cc5d1e72f 100644 --- a/app/javascript/stylesheets/style.scss +++ b/app/javascript/stylesheets/style.scss @@ -23,7 +23,7 @@ dt { #mobile-navbar { &.not-production { - // background-color: #ec6fde !important; + background-color: #ec6fde !important; } border-bottom: 2px solid $color-primary-4; }