Skip to content

Commit

Permalink
fix empty ai decisions
Browse files Browse the repository at this point in the history
  • Loading branch information
ramazanoacar committed Oct 15, 2024
1 parent 5443abe commit 237a052
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
40 changes: 23 additions & 17 deletions github_tracker_bot/mongo_data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,20 +554,26 @@ def set_qualified_daily_contribution_streak(
raise

def update_ai_decisions(self, user: User, new_decisions: List[AIDecision]) -> None:
for new_decision in new_decisions:
for user_ai_decision in user.ai_decisions[0]:
if (
user_ai_decision.repository == new_decision.repository
and user_ai_decision.date == new_decision.date
):
user_ai_decision.response = new_decision.response
for commit in new_decision.commit_hashes:
if commit not in user_ai_decision.commit_hashes:
user_commit_hashes = user_ai_decision.commit_hashes
if type(user_commit_hashes) != list:
user_commit_hashes = user_commit_hashes.split(",")
user_commit_hashes.extend(commit)
user_ai_decision.commit_hashes = user_commit_hashes
break
else:
user.ai_decisions[0].extend([new_decision])
logger.info(f"Updating AI decisions for user {user.user_handle}")
logger.info(f"New decisions: {new_decisions}")
logger.info(f"Old decisions: {user.ai_decisions}")
if len(user.ai_decisions) == 0:
user.ai_decisions = [new_decisions]
else:
for new_decision in new_decisions:
for user_ai_decision in user.ai_decisions[0]:
if (
user_ai_decision.repository == new_decision.repository
and user_ai_decision.date == new_decision.date
):
user_ai_decision.response = new_decision.response
for commit in new_decision.commit_hashes:
if commit not in user_ai_decision.commit_hashes:
user_commit_hashes = user_ai_decision.commit_hashes
if type(user_commit_hashes) != list:
user_commit_hashes = user_commit_hashes.split(",")
user_commit_hashes.extend(commit)
user_ai_decision.commit_hashes = user_commit_hashes
break
else:
user.ai_decisions[0].extend([new_decision])
2 changes: 1 addition & 1 deletion leader_bot/sheet_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
from github_tracker_bot.mongo_data_handler import AIDecision
from helpers import get_monthly_user_data_from_ai_decisions, get_since_until_y_m_d
from config import GOOGLE_CREDENTIALS

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
Expand Down Expand Up @@ -487,6 +486,7 @@ def delete_user(discord_handle: str):

def write_all_data_of_user_to_csv_by_month(file_path: str, username: str, date: str):
from db_functions import get_ai_decisions_by_user_and_timeframe
from helpers import get_monthly_user_data_from_ai_decisions, get_since_until_y_m_d

try:
since, until = get_since_until_y_m_d(date)
Expand Down

0 comments on commit 237a052

Please sign in to comment.