Skip to content

Commit

Permalink
fix(codecov): fix issues with thread crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Dec 19, 2024
1 parent 82b6f2a commit 1c5c1b3
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,36 @@ def update_crowdin():
"""
client = CrowdinClient(token=os.environ['CROWDIN_TOKEN'])

project_data = client.projects.list_projects()['data']
project_data = []

offset = 0
limit = 500
while True:
print(f'Fetching projects from Crowdin API, offset: {offset}')
result = client.projects.list_projects(
limit=limit,
offset=offset,
)
if not result or not result.get('data'):
print('No projects found.')
break

project_data.extend(result['data'])
offset += limit

for project in tqdm(
iterable=project_data,
desc='Updating Crowdin data',
):
project_name = project['data']['name']
project_id = project['data']['id']
data = client.translation_status.get_project_progress(projectId=project_id)['data']

progress_result = client.translation_status.get_project_progress(projectId=project_id)
if not progress_result or not progress_result.get('data'):
print(f'No progress data found for project: {project_name}')
continue

data = progress_result['data']
file_path = os.path.join(BASE_DIR, 'crowdin', project_name.replace(' ', '_'))
helpers.write_json_files(file_path=file_path, data=data)

Expand Down

0 comments on commit 1c5c1b3

Please sign in to comment.