32
32
generation_time = datetime .now (timezone .utc )
33
33
34
34
35
+ def get_previous_completion (language_code : str ) -> float :
36
+ try :
37
+ with open ('index.json' ) as f :
38
+ previous_data = json .load (f )
39
+ for item in previous_data :
40
+ if item ['language' ]['code' ] == language_code :
41
+ return item .get ('completion' , 0.0 )
42
+ except FileNotFoundError :
43
+ pass
44
+ return 0.0
45
+
46
+
35
47
def get_completion_progress () -> Iterator ['LanguageProjectData' ]:
36
48
with TemporaryDirectory () as clones_dir :
37
49
Repo .clone_from (
@@ -76,6 +88,10 @@ def get_project_data(
76
88
translators_data = TranslatorsData (0 , False )
77
89
visitors_num = 0
78
90
branch = None
91
+
92
+ previous_completion = get_previous_completion (language .code )
93
+ change = completion - previous_completion
94
+
79
95
return LanguageProjectData (
80
96
language ,
81
97
repo ,
@@ -87,6 +103,7 @@ def get_project_data(
87
103
in_switcher = languages_built .get (language .code ),
88
104
uses_platform = language .code in contribute .pulling_from_transifex ,
89
105
contribution_link = contribute .get_contrib_link (language .code , repo ),
106
+ change = change ,
90
107
)
91
108
92
109
@@ -102,6 +119,7 @@ class LanguageProjectData:
102
119
in_switcher : bool | None
103
120
uses_platform : bool
104
121
contribution_link : str | None
122
+ change : float
105
123
106
124
107
125
if __name__ == '__main__' :
@@ -118,4 +136,4 @@ class LanguageProjectData:
118
136
Path ('index.html' ).write_text (output )
119
137
Path ('index.json' ).write_text (
120
138
json .dumps (completion_progress , indent = 2 , default = asdict )
121
- )
139
+ )
0 commit comments