Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 8c4ece8

Browse files
committed
debug ci
1 parent 1167922 commit 8c4ece8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/sentiment/post_classification.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ module Sentiment
55
class PostClassification
66
def self.backfill_query(from_post_id: nil, max_age_days: nil)
77
available_classifier_names =
8-
DiscourseAi::Sentiment::SentimentSiteSettingJsonSchema.values.map(&:model_name).sort
8+
DiscourseAi::Sentiment::SentimentSiteSettingJsonSchema
9+
.values
10+
.map { |mc| mc.model_name.downcase }
11+
.sort
912

1013
base_query =
1114
Post
@@ -24,7 +27,9 @@ def self.backfill_query(from_post_id: nil, max_age_days: nil)
2427
.group("posts.id")
2528
.having(<<~SQL, available_classifier_names)
2629
COUNT(crs.model_used) = 0
27-
OR array_agg(DISTINCT crs.model_used ORDER BY crs.model_used)::text[] IS DISTINCT FROM array[?]
30+
OR array_agg(
31+
DISTINCT LOWER(crs.model_used) ORDER BY LOWER(crs.model_used)
32+
)::text[] IS DISTINCT FROM array[?]
2833
SQL
2934

3035
base_query = base_query.where("posts.id >= ?", from_post_id.to_i) if from_post_id.present?

spec/lib/modules/sentiment/post_classification_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ def check_classification_for(post)
159159
Fabricate(:classification_result, target: classified_post, model_used: cm["model_name"])
160160
end
161161

162+
pp Post
163+
.where(id: classified_post.id)
164+
.joins(<<~SQL)
165+
LEFT JOIN classification_results crs
166+
ON crs.target_id = posts.id
167+
AND crs.target_type = 'Post'
168+
AND crs.classification_type = 'sentiment'
169+
SQL
170+
.select("array_agg(DISTINCT crs.model_used ORDER BY crs.model_used ASC)")
171+
pp "\n"
172+
pp DiscourseAi::Sentiment::SentimentSiteSettingJsonSchema.values.map(&:model_name).sort
173+
162174
posts = described_class.backfill_query
163175
expect(posts).not_to include(classified_post)
164176

0 commit comments

Comments
 (0)