Skip to content

Commit

Permalink
Merge pull request #188 from DerickIT/main
Browse files Browse the repository at this point in the history
Automatic update readme file learning status script
  • Loading branch information
DerickIT authored Jun 29, 2024
2 parents 2e7ab58 + 57df973 commit 1871612
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Derick_EICL1st.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Maybe 90 %

- We found this turtle on a rainy day and fed it every day. It loves to eat meat and sometimes opens its mouth wide. We all loved it very much.

### 2024.6.29
- test commit status

听写笔记的方法和演示,以 https://www.bilibili.com/video/BV1U7411a7xG 为例,仅参考:

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ LXDAO Host 的英语残酷共学第 1 期将着重加强**听和说**的训练
| Tb ||||| ⭕️ | | | | | | | | | | | | | | | | |
| Marcus |||| || | | | | | | | | | | | | | | | |
| Uint8 |||||| | | | | | | | | | | | | | | | |

<!-- END_COMMIT_TABLE -->


Expand Down
23 changes: 14 additions & 9 deletions sync_status_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@
date_range = [(start_date + timedelta(days=x)).strftime("%m.%d") for x in range((end_date - start_date).days + 1)]

# 获取当前北京时间
current_date = datetime.now(beijing_tz).replace(hour=0, minute=0, second=0, microsecond=0)
current_date = datetime.now(beijing_tz)

# 获取每个用户在每一天的提交状态
user_commits = {user: {} for user in contributors}
for date in date_range:
day = datetime.strptime(date, "%m.%d").replace(year=2024, tzinfo=beijing_tz)
if day >= current_date:
continue # 跳过今天及以后的日期
next_day = day + timedelta(days=1)
commits = repo.get_commits(since=day, until=next_day)
day_start = datetime.strptime(date, "%m.%d").replace(year=2024, tzinfo=beijing_tz)
day_end = day_start + timedelta(days=1)
if day_end > current_date:
day_end = current_date
if day_start >= current_date:
continue # 跳过未来的日期

commits = repo.get_commits(since=day_start, until=day_end)
for commit in commits:
if commit.author:
user_commits[commit.author.login][date] = "✅"
commit_date = commit.commit.author.date.astimezone(beijing_tz)
commit_date_str = commit_date.strftime("%m.%d")
user_commits[commit.author.login][commit_date_str] = "✅"

# 检查是否有人在一周内超过两天没有提交
def check_weekly_status(user_commits, user, date):
Expand All @@ -51,8 +56,8 @@ def check_weekly_status(user_commits, user, date):
row = f"| {user} |"
for date in date_range:
day = datetime.strptime(date, "%m.%d").replace(year=2024, tzinfo=beijing_tz)
if day >= current_date:
status = " " # 今天及以后的日期显示为空白
if day > current_date:
status = " " # 未来的日期显示为空白
else:
status = check_weekly_status(user_commits, user, date)
row += f" {status} |"
Expand Down

0 comments on commit 1871612

Please sign in to comment.