FIX: Filter classification type using the correct column (#286)

This commit is contained in:
Roman Rizzi 2023-11-08 14:58:35 -03:00 committed by GitHub
parent 231cf91cc2
commit 458e66aef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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