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

Commit d52030a

Browse files
committed
Make sure model_name order is consistent.
1 parent 1167922 commit d52030a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-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?

0 commit comments

Comments
 (0)