Skip to content

Commit 0b34ffe

Browse files
Move to speed up
1 parent 96a0395 commit 0b34ffe

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

completion.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import subprocess
23
from dataclasses import dataclass
34
from functools import cache
45
from pathlib import Path
@@ -20,7 +21,7 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]:
2021
]
2122

2223

23-
def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData', str]:
24+
def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData', str, float]:
2425
clone_path = Path(clones_dir, repo)
2526
for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + ['master']:
2627
try:
@@ -44,8 +45,19 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData'
4445
hide_reserved=False,
4546
api_url='',
4647
).completion
47-
return completion, translators_data, branch
4848

49+
subprocess.run(['git', 'checkout', 'HEAD@{30 days ago}'], cwd=clone_path, check=True)
50+
with TemporaryDirectory() as tmpdir:
51+
month_ago_completion = potodo.merge_and_scan_path(
52+
clone_path,
53+
pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'),
54+
merge_path=Path(tmpdir),
55+
hide_reserved=False,
56+
api_url='',
57+
).completion
58+
59+
change = completion - month_ago_completion
60+
return completion, translators_data, branch, change
4961

5062
@dataclass(frozen=True)
5163
class TranslatorsData:

generate.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ 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-
subprocess.run(['git', 'checkout', 'HEAD@{30 days ago}'], cwd=repo_dir, check=True)
66-
return get_completion(clones_dir, repo)[0]
67-
68-
6963
def get_project_data(
7064
language: Language,
7165
repo: str | None,
@@ -75,9 +69,7 @@ def get_project_data(
7569
) -> 'LanguageProjectData':
7670
built = language.code in languages_built
7771
if repo:
78-
completion, translators_data, branch = get_completion(clones_dir, repo)
79-
month_ago_completion = get_month_ago_completion(clones_dir, repo)
80-
change = completion - month_ago_completion
72+
completion, translators_data, branch, change = get_completion(clones_dir, repo)
8173
visitors_num = get_number_of_visitors(language.code, http) if built else 0
8274
else:
8375
completion = 0.0

0 commit comments

Comments
 (0)