Add size
This commit is contained in:
parent
6830f121ed
commit
9afef8904b
|
@ -101,4 +101,20 @@ module ApplicationHelper
|
||||||
"alert-#{type}"
|
"alert-#{type}"
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@ rd-widget ng-show='build_list.packages'
|
||||||
th
|
th
|
||||||
th= t('activerecord.attributes.build_list/package.fullname')
|
th= t('activerecord.attributes.build_list/package.fullname')
|
||||||
th= t('activerecord.attributes.build_list/package.name')
|
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.epoch')
|
||||||
th= t('activerecord.attributes.build_list/package.version')
|
th= t('activerecord.attributes.build_list/package.version')
|
||||||
th= t('activerecord.attributes.build_list/package.release')
|
th= t('activerecord.attributes.build_list/package.release')
|
||||||
|
@ -27,6 +28,8 @@ rd-widget ng-show='build_list.packages'
|
||||||
| {{::package.fullname}}
|
| {{::package.fullname}}
|
||||||
td
|
td
|
||||||
| {{::package.name}}
|
| {{::package.name}}
|
||||||
|
td
|
||||||
|
| {{::package.size}}
|
||||||
td
|
td
|
||||||
| {{::package.epoch}}
|
| {{::package.epoch}}
|
||||||
td
|
td
|
||||||
|
|
|
@ -49,6 +49,11 @@ json.build_list do
|
||||||
json.packages @build_list.packages do |package|
|
json.packages @build_list.packages do |package|
|
||||||
json.(package, :id, :name, :fullname, :release, :version, :sha1, :epoch)
|
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
|
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?
|
if @build_list.save_to_platform.main?
|
||||||
json.dependent_projects dependent_projects(package) do |project, packages|
|
json.dependent_projects dependent_projects(package) do |project, packages|
|
||||||
|
|
|
@ -64,6 +64,7 @@ en:
|
||||||
build_list/package:
|
build_list/package:
|
||||||
name: Name
|
name: Name
|
||||||
fullname: Fullname
|
fullname: Fullname
|
||||||
|
size: Size
|
||||||
epoch: Epoch
|
epoch: Epoch
|
||||||
release: Release
|
release: Release
|
||||||
version: Version
|
version: Version
|
||||||
|
|
|
@ -63,6 +63,7 @@ ru:
|
||||||
build_list/package:
|
build_list/package:
|
||||||
name: Название
|
name: Название
|
||||||
fullname: Полное имя
|
fullname: Полное имя
|
||||||
|
size: Размер
|
||||||
epoch: Эпоха
|
epoch: Эпоха
|
||||||
release: Релиз
|
release: Релиз
|
||||||
version: Версия
|
version: Версия
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddSizeToBuildListPackages < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :build_list_packages, :size, :bigint, default: 0
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -56,6 +56,7 @@ ActiveRecord::Schema.define(version: 20190210143409) do
|
||||||
t.string "sha1"
|
t.string "sha1"
|
||||||
t.integer "epoch"
|
t.integer "epoch"
|
||||||
t.text "dependent_packages"
|
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)"
|
t.index :name=>"build_list_packages_ordering", :expression=>"lower((name)::text), length((name)::text)"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue