From e3f476a739005da2f4b0770f1a241b7dd2287e56 Mon Sep 17 00:00:00 2001 From: stan Date: Fri, 14 Feb 2025 23:38:27 +0000 Subject: [PATCH 1/2] Add "diff" to json --- generate.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/generate.py b/generate.py index a90cf1709..457e02d45 100644 --- a/generate.py +++ b/generate.py @@ -32,6 +32,18 @@ generation_time = datetime.now(timezone.utc) +def get_previous_completion(language_code: str) -> float: + try: + with open('index.json') as f: + previous_data = json.load(f) + for item in previous_data: + if item['language']['code'] == language_code: + return item.get('completion', 0.0) + except FileNotFoundError: + pass + return 0.0 + + def get_completion_progress() -> Iterator['LanguageProjectData']: with TemporaryDirectory() as clones_dir: Repo.clone_from( @@ -76,6 +88,10 @@ def get_project_data( translators_data = TranslatorsData(0, False) visitors_num = 0 branch = None + + previous_completion = get_previous_completion(language.code) + change = completion - previous_completion + return LanguageProjectData( language, repo, @@ -87,6 +103,7 @@ def get_project_data( in_switcher=languages_built.get(language.code), uses_platform=language.code in contribute.pulling_from_transifex, contribution_link=contribute.get_contrib_link(language.code, repo), + change=change, ) @@ -102,6 +119,7 @@ class LanguageProjectData: in_switcher: bool | None uses_platform: bool contribution_link: str | None + change: float if __name__ == '__main__': @@ -118,4 +136,4 @@ class LanguageProjectData: Path('index.html').write_text(output) Path('index.json').write_text( json.dumps(completion_progress, indent=2, default=asdict) - ) + ) \ No newline at end of file From c9c57b551b641677d2964ed131f81cc77c82865d Mon Sep 17 00:00:00 2001 From: stan Date: Sat, 15 Feb 2025 00:02:40 +0000 Subject: [PATCH 2/2] Temp change to workflow --- .github/workflows/update.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 05a68543b..c3cefc58e 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -21,6 +21,11 @@ jobs: - run: sudo apt-get install -y gettext - run: uv run generate.py # generates "index.html" - run: mkdir -p build && cp index.* style.css build + - run: cd build && cat index.json + - uses: actions/upload-artifact@v4 + with: + name: build + path: build - name: Deploy 🚀 if: github.event_name != 'pull_request' uses: JamesIves/github-pages-deploy-action@v4