Skip to content

Commit

Permalink
Update sync_status_readme.py add perfect_attendance_users
Browse files Browse the repository at this point in the history
  • Loading branch information
DerickIT authored Aug 6, 2024
1 parent 934001d commit 2c57ab1
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions sync_status_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,16 @@ def update_readme(content):

for row in table_rows:
match = re.match(r'\|\s*([^|]+)\s*\|', row)
if match:
display_name = match.group(1).strip()
if display_name: # 检查 display_name 是否为非空
existing_users.add(display_name)
new_table.append(generate_user_row(display_name))
if match:
display_name = match.group(1).strip()
if display_name: # 检查 display_name 是否为非空
existing_users.add(display_name)
new_table.append(generate_user_row(display_name))
else:
logging.warning(
f"Skipping empty display name in row: {row}")
else:
logging.warning(f"Skipping empty display name in row: {row}")
else:
logging.warning(f"Skipping invalid row: {row}")
logging.warning(f"Skipping invalid row: {row}")

new_users = set(get_all_user_files()) - existing_users
for user in new_users:
Expand Down Expand Up @@ -345,8 +346,23 @@ def calculate_statistics(content):
rows = table_content.split('\n')[2:] # Skip header and separator rows

total_participants = len(rows)
eliminated_participants = sum(1 for row in rows if '❌' in row)
completed_participants = total_participants - eliminated_participants
eliminated_participants = 0
completed_participants = 0
perfect_attendance_users = []

for row in rows:
user_name = row.split('|')[1].strip()
# Exclude first and last empty elements
statuses = [status.strip() for status in row.split('|')[2:-1]]

if '❌' in statuses:
eliminated_participants += 1
elif all(status == '✅' for status in statuses):
completed_participants += 1
perfect_attendance_users.append(user_name)
elif all(status in ['✅', '⭕️', ' '] for status in statuses):
completed_participants += 1

elimination_rate = (eliminated_participants /
total_participants) * 100 if total_participants > 0 else 0
fork_count = get_fork_count()
Expand All @@ -356,7 +372,8 @@ def calculate_statistics(content):
'completed_participants': completed_participants,
'eliminated_participants': eliminated_participants,
'elimination_rate': elimination_rate,
'fork_count': fork_count
'fork_count': fork_count,
'perfect_attendance_users': perfect_attendance_users
}


Expand Down Expand Up @@ -384,6 +401,7 @@ def main():
stats_content = f"\n\n## 统计数据\n\n"
stats_content += f"- 总参与人数: {stats['total_participants']}\n"
stats_content += f"- 完成人数: {stats['completed_participants']}\n"
stats_content += f"- 全勤用户: {', '.join(stats['perfect_attendance_users'])}\n"
stats_content += f"- 淘汰人数: {stats['eliminated_participants']}\n"
stats_content += f"- 淘汰率: {stats['elimination_rate']:.2f}%\n"
stats_content += f"- Fork人数: {stats['fork_count']}\n"
Expand Down

0 comments on commit 2c57ab1

Please sign in to comment.