diff --git a/apps/openchallenges/challenge-service/src/main/java/org/sagebionetworks/openchallenges/challenge/service/service/ChallengeAnalyticsService.java b/apps/openchallenges/challenge-service/src/main/java/org/sagebionetworks/openchallenges/challenge/service/service/ChallengeAnalyticsService.java index 4e51c28445..aa2732b3a4 100644 --- a/apps/openchallenges/challenge-service/src/main/java/org/sagebionetworks/openchallenges/challenge/service/service/ChallengeAnalyticsService.java +++ b/apps/openchallenges/challenge-service/src/main/java/org/sagebionetworks/openchallenges/challenge/service/service/ChallengeAnalyticsService.java @@ -15,7 +15,10 @@ public ChallengesPerYearDto getChallengesPerYear() { Arrays.asList( "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024"); + + // The following line will be auto-updated by a script and should NOT be modified manually. List challengeCounts = + /* AUTO-UPDATE MARKER */ Arrays.asList(6, 9, 13, 17, 23, 29, 34, 41, 49, 59, 86, 97, 116, 135, 184, 243, 306, 317); Integer undatedChallengeCount = 171; diff --git a/apps/openchallenges/db-update/update_db_csv.py b/apps/openchallenges/db-update/update_db_csv.py index acd1cb56a3..888db4d3a2 100644 --- a/apps/openchallenges/db-update/update_db_csv.py +++ b/apps/openchallenges/db-update/update_db_csv.py @@ -1,4 +1,5 @@ import os +import re import csv import gspread import numpy as np @@ -7,6 +8,11 @@ GOOGLE_SHEET_TITLE = "OpenChallenges Data" CHALLENGE_FOLDER = "apps/openchallenges/challenge-service/src/main/resources/db" ORGANIZATION_FOLDER = "apps/openchallenges/organization-service/src/main/resources/db" +PLOT_FILE = ( + "apps/openchallenges/challenge-service/src/main/java/org/sagebionetworks/" + "openchallenges/challenge/service/service/ChallengeAnalyticsService.java" +) +UPDATE_MARKER = r"(\/\* AUTO-UPDATE MARKER \*\/\s+)" # capture as a group to preserve def output_csv(df, output_filename, output_folder="", print_row=False): @@ -216,6 +222,18 @@ def main(gc): output_csv(sub_types, "submission_types.csv", output_folder=CHALLENGE_FOLDER, print_row=True) + # Update static plot numbers (displayed on homepage). + updated_plot_numbers = wks.worksheet("(plot) challenges_by_year").acell("D3").value + with open(PLOT_FILE, "r", encoding="utf-8") as file: + curr_content = file.read() + updated_content = re.sub( + UPDATE_MARKER + r"Arrays.asList\([\d, ]+\);", + r"\1" + updated_plot_numbers, # replace but keep reserved group (\1) + curr_content, + ) + with open(PLOT_FILE, "w", encoding="utf-8") as file: + file.write(updated_content) + if __name__ == "__main__": google_client = gspread.service_account(filename="service_account.json")