1414
1515LOGGER = logging .getLogger (__name__ )
1616
17- YEAR_TABLE_HEADER = """\
18- ## {year}
19-
20- | Month | Builds | Images | Commits |
21- | ---------------------- | ------ | ------ | ------- |
22- """
2317
24-
25- def build_monthly_table_line (year_month_file : Path ) -> str :
18+ def calculate_monthly_stat (year_month_file : Path ) -> tuple [int , int , int ]:
2619 year_month_file_content = year_month_file .read_text ()
27- images = year_month_file_content . count ( "Build manifest" )
20+
2821 builds = sum (
2922 "jupyter/base-notebook" in line and "aarch64" not in line
3023 for line in year_month_file_content .split ("\n " )
3124 )
25+
26+ images = year_month_file_content .count ("Build manifest" )
27+
3228 year_month = year_month_file .stem
3329 current_month = datetime .date (
3430 year = int (year_month [:4 ]), month = int (year_month [5 :]), day = 1
@@ -50,7 +46,7 @@ def build_monthly_table_line(year_month_file: Path) -> str:
5046 future .wait ()
5147 commits = len (future .stdout .splitlines ())
5248
53- return f"| [` { year_month } `](./ { year_month } ) | { builds : <6 } | { images : <6 } | { commits : <7 } | \n "
49+ return builds , images , commits
5450
5551
5652def regenerate_home_wiki_page (wiki_dir : Path ) -> None :
@@ -64,10 +60,26 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
6460 : wiki_home_content .find (YEAR_MONTHLY_TABLES ) + len (YEAR_MONTHLY_TABLES )
6561 ]
6662
63+ YEAR_TABLE_HEADER = """\
64+ ## {year}
65+
66+ | Month | Builds | Images | Commits |
67+ | ---------------------- | ------ | ------ | ------- |
68+ """
69+
6770 for year_dir in sorted ((wiki_dir / "monthly-files" ).glob ("*" ), reverse = True ):
6871 wiki_home_content += "\n " + YEAR_TABLE_HEADER .format (year = year_dir .name )
72+ year_builds , year_images , year_commits = 0 , 0 , 0
6973 for year_month_file in sorted (year_dir .glob ("*.md" ), reverse = True ):
70- wiki_home_content += build_monthly_table_line (year_month_file )
74+ builds , images , commits = calculate_monthly_stat (year_month_file )
75+ year_builds += builds
76+ year_images += images
77+ 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 "
80+ wiki_home_content += monthly_line
81+ year_total_line = f"| **Total** | { year_builds : <6} | { year_images : <6} | { year_commits : <7} |\n "
82+ wiki_home_content += year_total_line
7183
7284 wiki_home_file .write_text (wiki_home_content )
7385 LOGGER .info ("Updated Home page" )
0 commit comments