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 1 commit
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.garbage_size = Garbage Size: %s
packages.owner = Owner
packages.creator = Creator
packages.name = Name
Expand Down
13 changes: 11 additions & 2 deletions routers/web/admin/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func Packages(ctx *context.Context) {
return
}

totalAvaibleBlobSize, err := packages_model.CalculateBlobSize(ctx, &packages_model.PackageFileSearchOptions{
PackageType: "all",
})
lunny marked this conversation as resolved.
Show resolved Hide resolved
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 +73,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"] = totalAvaibleBlobSize
ctx.Data["TotalGarbageBlobSize"] = totalBlobSize - totalAvaibleBlobSize
lunny marked this conversation as resolved.
Show resolved Hide resolved

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.garbage_size" (FileSize .TotalGarbageBlobSize)}})
</h4>
<div class="ui attached segment">
<form class="ui form ignore-dirty">
Expand Down