Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display unreferenced packages total size in package admin panel #22498

Merged
merged 4 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,7 @@ repos.size = Size

packages.package_manage_panel = Package Management
packages.total_size = Total Size: %s
packages.unreferenced_size = Unreferenced Size: %s
packages.owner = Owner
packages.creator = Creator
packages.name = Name
Expand Down
11 changes: 9 additions & 2 deletions routers/web/admin/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func Packages(ctx *context.Context) {
return
}

totalReferencedBlobSize, err := packages_model.CalculateBlobSize(ctx, &packages_model.PackageFileSearchOptions{})
if err != nil {
ctx.ServerError("CalculateBlobSize", err)
return
}

ctx.Data["Title"] = ctx.Tr("packages.title")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminPackages"] = true
Expand All @@ -65,8 +71,9 @@ func Packages(ctx *context.Context) {
ctx.Data["AvailableTypes"] = packages_model.TypeList
ctx.Data["SortType"] = sort
ctx.Data["PackageDescriptors"] = pds
ctx.Data["Total"] = total
ctx.Data["TotalBlobSize"] = totalBlobSize
ctx.Data["TotalCount"] = total
ctx.Data["TotalBlobSize"] = totalReferencedBlobSize
ctx.Data["TotalUnreferencedBlobSize"] = totalBlobSize - totalReferencedBlobSize

pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
pager.AddParamString("q", query)
Expand Down
4 changes: 3 additions & 1 deletion templates/admin/packages/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<div class="ui container">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.locale.Tr "admin.packages.package_manage_panel"}} ({{.locale.Tr "admin.total" .Total}}, {{.locale.Tr "admin.packages.total_size" (FileSize .TotalBlobSize)}})
{{.locale.Tr "admin.packages.package_manage_panel"}} ({{.locale.Tr "admin.total" .TotalCount}},
{{.locale.Tr "admin.packages.total_size" (FileSize .TotalBlobSize)}},
{{.locale.Tr "admin.packages.unreferenced_size" (FileSize .TotalUnreferencedBlobSize)}})
Comment on lines +7 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm wondering about: What is the benefit of showing the amount of wasted space?
Or is there somewhere a button to manually cleanup unreferenced packages?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could click on the "run cleanup job now" button. But I think this should prevent users from asking "I deleted x but the size stayed the same".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good, this button exists already, because otherwise my next suggestion would have been to display such a button.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, some users report me they found a bug there...

</h4>
<div class="ui attached segment">
<form class="ui form ignore-dirty">
Expand Down