Skip to content

Commit

Permalink
fix: avg sentiment calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowtham1729 committed Dec 18, 2023
1 parent 0d1ee70 commit 6fdc3b1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion applications/data_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,17 @@ def update_daily_analysis(self, news: News, date: str):
"""
UPDATE news_analysis
SET
average_sentiment = (SELECT AVG(sentiment) FROM news_news WHERE sentiment!=0),
average_sentiment =
(
SELECT
AVG(sentiment)
FROM
news_news
WHERE
sentiment!=0 AND
symbol = %s AND
DATE(publish_time) = %s
),
total_news = total_news + 1,
positive_news = positive_news + %s,
negative_news = negative_news + %s,
Expand All @@ -267,6 +277,8 @@ def update_daily_analysis(self, news: News, date: str):
WHERE symbol = %s AND date = %s
""",
(
news.symbol,
date,
1 if news.sentiment > 0 else 0,
1 if news.sentiment < 0 else 0,
1 if news.sentiment == 0 else 0,
Expand Down

0 comments on commit 6fdc3b1

Please sign in to comment.