15
15
LOGGER = logging .getLogger (__name__ )
16
16
17
17
18
- def calculate_monthly_stat (year_month_file : Path ) -> tuple [int , int , int ]:
18
+ def calculate_monthly_stat (
19
+ year_month_file : Path , year_month_date : datetime .date
20
+ ) -> tuple [int , int , int ]:
19
21
year_month_file_content = year_month_file .read_text ()
20
22
21
23
builds = sum (
@@ -25,20 +27,15 @@ def calculate_monthly_stat(year_month_file: Path) -> tuple[int, int, int]:
25
27
26
28
images = year_month_file_content .count ("Build manifest" )
27
29
28
- year_month = year_month_file .stem
29
- current_month = datetime .date (
30
- year = int (year_month [:4 ]), month = int (year_month [5 :]), day = 1
31
- )
32
- next_month = current_month + relativedelta .relativedelta (months = 1 )
33
30
with plumbum .local .env (TZ = "UTC" ):
34
31
future = (
35
32
git [
36
33
"log" ,
37
34
"--oneline" ,
38
35
"--since" ,
39
- f"{ current_month } .midnight" ,
36
+ f"{ year_month_date } .midnight" ,
40
37
"--until" ,
41
- f"{ next_month } .midnight" ,
38
+ f"{ year_month_date + relativedelta . relativedelta ( months = 1 ) } .midnight" ,
42
39
"--first-parent" ,
43
40
]
44
41
& plumbum .BG
@@ -63,22 +60,39 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
63
60
YEAR_TABLE_HEADER = """\
64
61
## {year}
65
62
66
- | Month | Builds | Images | Commits |
67
- | ---------------------- | ------ | ------ | ------- |
63
+ | Month | Builds | Images | Commits |
64
+ | ---------------------- | ------ | ------ | ----------------------------------------------------------------------------------------------- |
68
65
"""
69
66
67
+ GITHUB_COMMITS_URL = (
68
+ "[{}](https://github.com/jupyter/docker-stacks/commits/main/?since={}&until={})"
69
+ )
70
+
70
71
for year_dir in sorted ((wiki_dir / "monthly-files" ).glob ("*" ), reverse = True ):
71
72
wiki_home_content += "\n " + YEAR_TABLE_HEADER .format (year = year_dir .name )
72
73
year_builds , year_images , year_commits = 0 , 0 , 0
73
74
for year_month_file in sorted (year_dir .glob ("*.md" ), reverse = True ):
74
- builds , images , commits = calculate_monthly_stat (year_month_file )
75
+ year_month = year_month_file .stem
76
+ year_month_date = datetime .date (
77
+ year = int (year_month [:4 ]), month = int (year_month [5 :]), day = 1
78
+ )
79
+ builds , images , commits = calculate_monthly_stat (
80
+ year_month_file , year_month_date
81
+ )
75
82
year_builds += builds
76
83
year_images += images
77
84
year_commits += commits
78
- year_month = year_month_file .stem
79
- monthly_line = f"| [`{ year_month } `](./{ year_month } ) | { builds : <6} | { images : <6} | { commits : <7} |\n "
85
+ commits_url = GITHUB_COMMITS_URL .format (
86
+ commits ,
87
+ year_month_date ,
88
+ year_month_date + relativedelta .relativedelta (day = 31 ),
89
+ )
90
+ monthly_line = f"| [`{ year_month } `](./{ year_month } ) | { builds : <6} | { images : <6} | { commits_url : <95} |\n "
80
91
wiki_home_content += monthly_line
81
- year_total_line = f"| **Total** | { year_builds : <6} | { year_images : <6} | { year_commits : <7} |\n "
92
+ year_commits_url = GITHUB_COMMITS_URL .format (
93
+ year_commits , f"{ year_dir .name } -01-01" , f"{ year_dir .name } -12-31"
94
+ )
95
+ year_total_line = f"| **Total** | { year_builds : <6} | { year_images : <6} | { year_commits_url : <95} |\n "
82
96
wiki_home_content += year_total_line
83
97
84
98
wiki_home_file .write_text (wiki_home_content )
0 commit comments