diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 13da56806de6e..17ebed5a8c1e6 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -45,6 +45,12 @@ jobs: - name: Build Pandas uses: ./.github/actions/build_pandas + - name: Set up maintainers cache + uses: actions/cache@v3 + with: + path: maintainers.json + key: maintainers + - name: Build website run: python web/pandas_web.py web/pandas --target-path=web/build diff --git a/web/pandas_web.py b/web/pandas_web.py index 62539574543a9..3e5b089cab64a 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -27,6 +27,7 @@ import collections import datetime import importlib +import json import operator import os import pathlib @@ -157,6 +158,18 @@ def maintainers_add_info(context): Given the active maintainers defined in the yaml file, it fetches the GitHub user information for them. """ + timestamp = time.time() + + cache_file = pathlib.Path("maintainers.json") + if cache_file.is_file(): + with open(cache_file) as f: + context["maintainers"] = json.load(f) + # refresh cache after 1 hour + if (timestamp - context["maintainers"]["timestamp"]) < 3_600: + return context + + context["maintainers"]["timestamp"] = timestamp + repeated = set(context["maintainers"]["active"]) & set( context["maintainers"]["inactive"] ) @@ -171,6 +184,10 @@ def maintainers_add_info(context): return context resp.raise_for_status() context["maintainers"][f"{kind}_with_github_info"].append(resp.json()) + + with open(cache_file, "w") as f: + json.dump(context["maintainers"], f) + return context @staticmethod