summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorMarius Peter <wtt@marius-peter.com>2025-01-02 19:11:34 +0100
committerMarius Peter <wtt@marius-peter.com>2025-01-02 19:11:34 +0100
commitb34d2b51174b511d59fa324d9f42abc75a1fa09a (patch)
tree7fa57e3e2e33f43bc7ae787cfbba414cc66ac8df /app/services
parent175111f9d84354dce00503525649197e9acb6382 (diff)
Ensure session[:id] before scoring: all tests now pass.HEADmaster
Never too late for all tests to pass...
Diffstat (limited to 'app/services')
-rw-r--r--app/services/tartiflette_scoring_service.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/services/tartiflette_scoring_service.rb b/app/services/tartiflette_scoring_service.rb
index 6df2f0c..4e4bc76 100644
--- a/app/services/tartiflette_scoring_service.rb
+++ b/app/services/tartiflette_scoring_service.rb
@@ -10,11 +10,11 @@ class TartifletteScoringService
end
def self.submit_scores(tartiflette, scores, session)
- scores.each do |criterium_id, score_params|
+ scores.each do |scoring_criterium_id, score_params|
Score.create!(
- session_id: session.id,
+ session_id: session[:id],
tartiflette: tartiflette,
- scoring_criterium_id: criterium_id,
+ scoring_criterium_id: scoring_criterium_id,
value: score_params[:value]
)
end
@@ -32,6 +32,8 @@ class TartifletteScoringService
raise StandardError, "Failed to update score: #{e.message}"
end
+ private
+
def self.average_score(tartiflette)
tartiflette.scores.average(:value).to_f
end
@@ -50,7 +52,7 @@ class TartifletteScoringService
.scores
.group_by { |score| score.scoring_criterium.category }
.transform_values do |scores|
- (scores.sum(&:value).to_f / scores.size).round(2)
+ scores.sum(&:value).to_f.round(2)
end
end
Copyright 2019--2025 Marius PETER