From cb591888f6ea06aca44ec9222c826fb2b10ee24c Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sun, 24 Nov 2024 21:49:09 +0100 Subject: [PATCH] Generate download plot from PyPi data --- src/napari_dashboard/gen_stat/pypi.py | 11 +++++++++++ src/napari_dashboard/get_webpage/html_gen.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/napari_dashboard/gen_stat/pypi.py b/src/napari_dashboard/gen_stat/pypi.py index 0ada7bc..924fc78 100644 --- a/src/napari_dashboard/gen_stat/pypi.py +++ b/src/napari_dashboard/gen_stat/pypi.py @@ -103,6 +103,17 @@ def get_pepy_download_per_day(session: Session, package: str): ) +def get_pypi_download_per_day(session: Session, package: str): + assert package == "napari", "We only collect data for napari now" + return dict( + session.query(PyPi.date, func.count(PyPi.timestamp)) + .filter(PyPi.project == package) + .filter(PyPi.ci_install.isnot(True)) + .group_by(PyPi.date) + .all() + ) + + def get_total_pypi_download(session: Session, packages: set[str]): return ( session.query(func.sum(PePyTotalDownloads.downloads)) diff --git a/src/napari_dashboard/get_webpage/html_gen.py b/src/napari_dashboard/get_webpage/html_gen.py index 68302a3..84a21df 100644 --- a/src/napari_dashboard/get_webpage/html_gen.py +++ b/src/napari_dashboard/get_webpage/html_gen.py @@ -31,8 +31,8 @@ get_download_info, get_download_per_operating_system, get_download_per_python_version, - get_pepy_download_per_day, get_per_country_download, + get_pypi_download_per_day, get_recent_releases_date, get_total_pypi_download, is_country, @@ -443,7 +443,7 @@ def generate_webpage( pypi_download_info = get_download_info( session, ["napari", "npe2", "napari-plugin-manager"] ) - napari_downloads_per_day = get_pepy_download_per_day(session, "napari") + napari_downloads_per_day = get_pypi_download_per_day(session, "napari") active_plugin_stats = get_active_packages( session, packages=valid_plugins, threshold=1500 )