Fix PyPI proxy UX and package stats calculation
- Fix artifact_count and total_size calculation to use Tags instead of Uploads, so PyPI cached packages show their stats correctly - Fix PackagePage dropdown menu positioning (use fixed position with backdrop) - Add system project detection for projects starting with "_" - Show Version as primary column for system projects, hide Tag column - Hide upload button for system projects (they're cache-only) - Rename section header to "Versions" for system projects - Fix test_projects_sort_by_name to exclude system projects from sort comparison
This commit is contained in:
@@ -2827,14 +2827,15 @@ def list_packages(
|
||||
db.query(func.count(Tag.id)).filter(Tag.package_id == pkg.id).scalar() or 0
|
||||
)
|
||||
|
||||
# Get unique artifact count and total size via uploads
|
||||
# Get unique artifact count and total size via tags
|
||||
# (PyPI proxy creates tags without uploads, so query from tags)
|
||||
artifact_stats = (
|
||||
db.query(
|
||||
func.count(func.distinct(Upload.artifact_id)),
|
||||
func.count(func.distinct(Tag.artifact_id)),
|
||||
func.coalesce(func.sum(Artifact.size), 0),
|
||||
)
|
||||
.join(Artifact, Upload.artifact_id == Artifact.id)
|
||||
.filter(Upload.package_id == pkg.id)
|
||||
.join(Artifact, Tag.artifact_id == Artifact.id)
|
||||
.filter(Tag.package_id == pkg.id)
|
||||
.first()
|
||||
)
|
||||
artifact_count = artifact_stats[0] if artifact_stats else 0
|
||||
@@ -2930,14 +2931,15 @@ def get_package(
|
||||
db.query(func.count(Tag.id)).filter(Tag.package_id == pkg.id).scalar() or 0
|
||||
)
|
||||
|
||||
# Get unique artifact count and total size via uploads
|
||||
# Get unique artifact count and total size via tags
|
||||
# (PyPI proxy creates tags without uploads, so query from tags)
|
||||
artifact_stats = (
|
||||
db.query(
|
||||
func.count(func.distinct(Upload.artifact_id)),
|
||||
func.count(func.distinct(Tag.artifact_id)),
|
||||
func.coalesce(func.sum(Artifact.size), 0),
|
||||
)
|
||||
.join(Artifact, Upload.artifact_id == Artifact.id)
|
||||
.filter(Upload.package_id == pkg.id)
|
||||
.join(Artifact, Tag.artifact_id == Artifact.id)
|
||||
.filter(Tag.package_id == pkg.id)
|
||||
.first()
|
||||
)
|
||||
artifact_count = artifact_stats[0] if artifact_stats else 0
|
||||
@@ -6280,14 +6282,14 @@ def get_package_stats(
|
||||
db.query(func.count(Tag.id)).filter(Tag.package_id == package.id).scalar() or 0
|
||||
)
|
||||
|
||||
# Artifact stats via uploads
|
||||
# Artifact stats via tags (tags exist for both user uploads and PyPI proxy)
|
||||
artifact_stats = (
|
||||
db.query(
|
||||
func.count(func.distinct(Upload.artifact_id)),
|
||||
func.count(func.distinct(Tag.artifact_id)),
|
||||
func.coalesce(func.sum(Artifact.size), 0),
|
||||
)
|
||||
.join(Artifact, Upload.artifact_id == Artifact.id)
|
||||
.filter(Upload.package_id == package.id)
|
||||
.join(Artifact, Tag.artifact_id == Artifact.id)
|
||||
.filter(Tag.package_id == package.id)
|
||||
.first()
|
||||
)
|
||||
artifact_count = artifact_stats[0] if artifact_stats else 0
|
||||
|
||||
Reference in New Issue
Block a user