From 458e66aef9bb746a81e95182ad956c8efe6c82da Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Wed, 8 Nov 2023 14:58:35 -0300 Subject: [PATCH] FIX: Filter classification type using the correct column (#286) --- lib/modules/sentiment/entry_point.rb | 4 ++-- spec/fabricators/classification_result_fabricator.rb | 9 ++++++--- spec/lib/modules/sentiment/entry_point_spec.rb | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/modules/sentiment/entry_point.rb b/lib/modules/sentiment/entry_point.rb index bacc7af6..37748735 100644 --- a/lib/modules/sentiment/entry_point.rb +++ b/lib/modules/sentiment/entry_point.rb @@ -36,7 +36,7 @@ module DiscourseAi WHERE t.archetype = 'regular' AND p.user_id > 0 AND - cr.classification_type = 'sentiment' AND + cr.model_used = 'sentiment' AND (p.created_at > :report_start AND p.created_at < :report_end) GROUP BY DATE_TRUNC('day', p.created_at) SQL @@ -80,7 +80,7 @@ module DiscourseAi WHERE t.archetype = 'regular' AND p.user_id > 0 AND - cr.classification_type = 'emotion' AND + cr.model_used = 'emotion' AND (p.created_at > :report_start AND p.created_at < :report_end) GROUP BY u.trust_level SQL diff --git a/spec/fabricators/classification_result_fabricator.rb b/spec/fabricators/classification_result_fabricator.rb index 4c6b619a..525c59cd 100644 --- a/spec/fabricators/classification_result_fabricator.rb +++ b/spec/fabricators/classification_result_fabricator.rb @@ -1,13 +1,16 @@ # frozen_string_literal: true -Fabricator(:classification_result) { target { Fabricate(:post) } } +Fabricator(:classification_result) do + target { Fabricate(:post) } + classification_type "sentiment" +end Fabricator(:sentiment_classification, from: :classification_result) do - classification_type "sentiment" + model_used "sentiment" classification { { negative: 72, neutral: 23, positive: 4 } } end Fabricator(:emotion_classification, from: :classification_result) do - classification_type "emotion" + model_used "emotion" classification { { negative: 72, neutral: 23, positive: 4 } } end diff --git a/spec/lib/modules/sentiment/entry_point_spec.rb b/spec/lib/modules/sentiment/entry_point_spec.rb index b970357c..b9e81a43 100644 --- a/spec/lib/modules/sentiment/entry_point_spec.rb +++ b/spec/lib/modules/sentiment/entry_point_spec.rb @@ -94,13 +94,13 @@ RSpec.describe DiscourseAi::Sentiment::EntryPoint do let(:emotion_2) do { sadness: 19, surprise: 63, neutral: 45, fear: 44, anger: 27, joy: 62, disgust: 30 } end - let(:classification_type) { "emotion" } + let(:model_used) { "emotion" } def emotion_classification(post, classification) Fabricate( :sentiment_classification, target: post, - classification_type: classification_type, + model_used: model_used, classification: classification, ) end