This commit is contained in:
Wedge 2020-01-22 14:50:51 +03:00
parent 6830f121ed
commit 9afef8904b
7 changed files with 33 additions and 1 deletions

View File

@ -101,4 +101,20 @@ module ApplicationHelper
"alert-#{type}"
end
end
def bytes_to_size(bytes)
sizes = [0, 1024, 1024*1024, 1024*1024*1024]
names = ['B', 'KiB', 'MiB', 'GiB']
sizes.each_with_index do |l, i|
low, high = sizes[i], sizes[i+1]
if bytes >= low && (!high || bytes < high)
if low == 0
sz = bytes
else
sz = (bytes.to_f / low).round(2)
end
return "#{sz}#{names[i]}"
end
end
end
end

View File

@ -7,6 +7,7 @@ rd-widget ng-show='build_list.packages'
th
th= t('activerecord.attributes.build_list/package.fullname')
th= t('activerecord.attributes.build_list/package.name')
th= t('activerecord.attributes.build_list/package.size')
th= t('activerecord.attributes.build_list/package.epoch')
th= t('activerecord.attributes.build_list/package.version')
th= t('activerecord.attributes.build_list/package.release')
@ -27,6 +28,8 @@ rd-widget ng-show='build_list.packages'
| {{::package.fullname}}
td
| {{::package.name}}
td
| {{::package.size}}
td
| {{::package.epoch}}
td

View File

@ -49,6 +49,11 @@ json.build_list do
json.packages @build_list.packages do |package|
json.(package, :id, :name, :fullname, :release, :version, :sha1, :epoch)
json.url "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{package.sha1}" if package.sha1
if package.size == 0
json.size 'N/A'
else
json.size bytes_to_size(package.size)
end
if @build_list.save_to_platform.main?
json.dependent_projects dependent_projects(package) do |project, packages|

View File

@ -64,6 +64,7 @@ en:
build_list/package:
name: Name
fullname: Fullname
size: Size
epoch: Epoch
release: Release
version: Version

View File

@ -63,6 +63,7 @@ ru:
build_list/package:
name: Название
fullname: Полное имя
size: Размер
epoch: Эпоха
release: Релиз
version: Версия

View File

@ -0,0 +1,5 @@
class AddSizeToBuildListPackages < ActiveRecord::Migration
def change
add_column :build_list_packages, :size, :bigint, default: 0
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190210143409) do
ActiveRecord::Schema.define(version: 20200121215842) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -56,6 +56,7 @@ ActiveRecord::Schema.define(version: 20190210143409) do
t.string "sha1"
t.integer "epoch"
t.text "dependent_packages"
t.integer "size", :limit=>8, :default=>0
t.index :name=>"build_list_packages_ordering", :expression=>"lower((name)::text), length((name)::text)"
end