Skip to content

Commit a2e695d

Browse files
Change to checking out repo 1 month ago
1 parent 644fec3 commit a2e695d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

generate.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ def get_completion_progress() -> Iterator['LanguageProjectData']:
6060
)
6161

6262

63+
def get_month_ago_completion(clones_dir: str, repo: str) -> float:
64+
repo_dir = Path(clones_dir, repo)
65+
repo_obj = Repo(repo_dir)
66+
current_commit = repo_obj.head.commit.hexsha
67+
subprocess.run(['git', 'checkout', 'HEAD@{30 days ago}'], cwd=repo_dir, check=True)
68+
month_ago_completion = get_completion(clones_dir, repo)[0]
69+
subprocess.run(['git', 'checkout', current_commit], cwd=repo_dir, check=True)
70+
return month_ago_completion
71+
72+
6373
def get_project_data(
6474
language: Language,
6575
repo: str | None,
@@ -70,17 +80,21 @@ def get_project_data(
7080
built = language.code in languages_built
7181
if repo:
7282
completion, translators_data, branch = get_completion(clones_dir, repo)
83+
month_ago_completion = get_month_ago_completion(clones_dir, 'cpython')
84+
change = completion - month_ago_completion
7385
visitors_num = get_number_of_visitors(language.code, http) if built else 0
7486
else:
7587
completion = 0.0
7688
translators_data = TranslatorsData(0, False)
89+
change = 0.0
7790
visitors_num = 0
7891
branch = None
7992
return LanguageProjectData(
8093
language,
8194
repo,
8295
branch,
8396
completion,
97+
change,
8498
translators_data,
8599
visitors_num,
86100
built,
@@ -96,6 +110,7 @@ class LanguageProjectData:
96110
repository: str | None
97111
branch: str | None
98112
completion: float
113+
change: float
99114
translators: TranslatorsData
100115
visitors: int
101116
built: bool

0 commit comments

Comments
 (0)