From b7664bc8bf30f70b334bab499045d8f7271a3d8b Mon Sep 17 00:00:00 2001 From: yingying Date: Tue, 21 Jan 2025 11:37:01 +0800 Subject: [PATCH] chore: fix ci --- server/insight/service/activity.py | 30 +++++++++++++++++------------- server/utils/insight.py | 5 +++++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/server/insight/service/activity.py b/server/insight/service/activity.py index 76977c45..54f62061 100644 --- a/server/insight/service/activity.py +++ b/server/insight/service/activity.py @@ -6,19 +6,23 @@ def get_activity_data(repo_name: str) -> List[Dict[str, int]]: url = f"https://oss.open-digger.cn/github/{repo_name}/activity_details.json" - response = requests.get(url) - data = response.json() - if not data: - return [] + try: + response = requests.get(url) + data = response.json() + if not data: + return [] - # Filter out only the monthly data (excluding quarters) - monthly_data = {k: v for k, v in data.items() if "-" in k} + # Filter out only the monthly data (excluding quarters) + monthly_data = {k: v for k, v in data.items() if "-" in k} - # Get the most recent month - most_recent_month_key = max(monthly_data.keys()) + # Get the most recent month + most_recent_month_key = max(monthly_data.keys()) - # Return the data for the most recent month - return [ - {"user": user, "value": value} - for user, value in monthly_data[most_recent_month_key] - ] + # Return the data for the most recent month + return [ + {"user": user, "value": value} + for user, value in monthly_data[most_recent_month_key] + ] + except Exception as e: + print(e) + return [] diff --git a/server/utils/insight.py b/server/utils/insight.py index aa73c71b..544098c9 100644 --- a/server/utils/insight.py +++ b/server/utils/insight.py @@ -41,6 +41,11 @@ def get_data(repo_name, metrics_mapping): print( f"Error fetching data from {url} (status code: {response.status_code})" ) + return { + "year": [], + "quarter": [], + "month": [], + } def format_result(data): result = []