chore(cleanup): Delete sentiment feature (#9304)

- The feature is unused, removing it for now, will bring it back with better models later.
This commit is contained in:
Pranav
2024-04-25 22:49:10 -07:00
committed by GitHub
parent 77db0d0701
commit ffd47081bd
11 changed files with 14 additions and 312 deletions

View File

@@ -1,5 +0,0 @@
module Enterprise::Message
def update_message_sentiments
::Enterprise::SentimentAnalysisJob.perform_later(self) if ENV.fetch('SENTIMENT_FILE_PATH', nil).present?
end
end

View File

@@ -1,45 +0,0 @@
module Enterprise::SentimentAnalysisHelper
extend ActiveSupport::Concern
included do
def opening_sentiments
records = incoming_messages.first(average_message_count)
average_sentiment(records)
end
def closing_sentiments
return unless resolved?
records = incoming_messages.last(average_message_count)
average_sentiment(records)
end
def average_sentiment(records)
{
label: average_sentiment_label(records),
score: average_sentiment_score(records)
}
end
private
def average_sentiment_label(records)
value = records.pluck(:sentiment).sum { |a| a['value'].to_i }
value.negative? ? 'negative' : 'positive'
end
def average_sentiment_score(records)
total = records.pluck(:sentiment).sum { |a| a['score'].to_f }
total / average_message_count
end
def average_message_count
# incoming_messages.count >= 10 ? 5 : ((incoming_messages.count / 2) - 1)
5
end
def incoming_messages
messages.incoming.where(private: false)
end
end
end