From b2687682a4e2b8c4fd2a874ea0741b6056fa0d38 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Fri, 16 Oct 2020 00:15:35 +0300 Subject: [PATCH] Handle no conflicts --- app/models/summary.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/summary.rb b/app/models/summary.rb index a524e53..03d7b53 100644 --- a/app/models/summary.rb +++ b/app/models/summary.rb @@ -10,7 +10,7 @@ class Summary end def most_conflicts - Conflicts.where(left: talk_ids, right: talk_ids).most.conflicts + Conflicts.where(left: talk_ids, right: talk_ids).most&.conflicts || 0 end def least_conflicts @@ -32,10 +32,10 @@ class Summary private def least_conflicts_for_single_talk - ConflictsForTalk.where(talk_id: talk_ids).least.conflicts + ConflictsForTalk.where(talk_id: talk_ids).least&.conflicts || 0 end def least_conflicts_between_two_talks - Conflicts.where(left: talk_ids, right: talk_ids).least.conflicts + Conflicts.where(left: talk_ids, right: talk_ids).least&.conflicts || 0 end end