diff --git a/app.rb b/app.rb index 2c7eb81..0978d3e 100644 --- a/app.rb +++ b/app.rb @@ -750,6 +750,7 @@ get "/gitbld/:id/:git_id" do @proj_name = prj_info[:projname] @proj_descr = prj_info[:descr] @git_name = git_info[:reponame] + @proj_id = params["id"] @build_id = prj.build_projects_git(prj_info[:id], git_info[:id], cfg.get_counter_path) @@ -786,6 +787,61 @@ get "/buildinfo/:build_id" do end end +get "/buildinforaw/:build_id" do + content_type "text/plain" + build_id = params["build_id"].to_i + if build_id > 0 + info = db.get_build_task_process_log(build_id) + unless info.nil? + if File.exist?(info[:errlogpath]) + output = "" + File.readlines(info[:errlogpath]).each do |line| + output << line + end + output + else + "Файла для чтения сборки уже не существует #{info[:errlogpath]}" + end + else + "Такого build id #{params["build_id"]} нет в базе" + end + else + "Ошибка чтения build id #{params["build_id"]}" + end +end + +get "/rpms" do + @page_name = "Список доступных пакетов" + @gits_rpms_list = db.get_gits_rpms + erb :rpmlistglobal +end + +get "/gitpackages/:git_id" do + repo = GitRepo.new(cfg.get_repo, db) + if repo.path.nil? + print_error_page(503, "Путь к репозиториям не существует") + else + git_info = repo.get_repo_short_info_by_id(params["git_id"].to_i) + if git_info.nil? + print_error_page(503, "Репозиторий исчез") + else + @page_name = "Список пакетов собранных из git репозитория #{git_info[:reponame]}" + rpms_lst = db.get_rpms_for_git(params["git_id"]) + if params["p"].nil? + @page = 1 + else + @page = params["p"].to_i + if @page < 1 + @page = 1 + end + end + items_per_page = cfg.get_items_per_page + @rpms_list = rpms_lst[(@page - 1) * items_per_page, items_per_page] + erb :rpmlistgit + end + end +end + not_found do status 404 @page_name = "Кто-то потерялся" diff --git a/classes/config.rb b/classes/config.rb index 75dbb7b..b15c504 100644 --- a/classes/config.rb +++ b/classes/config.rb @@ -70,4 +70,16 @@ class IniConfig "locks/counter" end end + + def get_items_per_page() + unless @config["pages"]["items_per_page"].nil? + res = @config["pages"]["items_per_page"].to_i + if res < 1 + res = 30 + end + res + else + 30 + end + end end diff --git a/classes/db.rb b/classes/db.rb index df9e708..0c4b1d7 100644 --- a/classes/db.rb +++ b/classes/db.rb @@ -1,7 +1,7 @@ require "sequel" cfg_internal = IniConfig.new() -Sequel.connect(cfg_internal.get_db) +$DDB = Sequel.connect(cfg_internal.get_db) class Repos < Sequel::Model(:repos) end @@ -254,7 +254,7 @@ class DBase end def after_fork() - Sequel.connect(@cfg.get_db) + $DDB = Sequel.connect(@cfg.get_db) end def save_rpm(build_id, path_to_rpm, rpm_name, git_id) @@ -262,4 +262,12 @@ class DBase @last_id = id BuildRpms.insert(build_id: build_id.to_i, rpm_id: id) end + + def get_gits_rpms() + $DDB["select t1.id, t1.reponame, count(*) as packages from repos as t1 join rpms as t2 on t2.repo_id = t1.id group by t1.id, t1.reponame order by t1.id"].all + end + + def get_rpms_for_git(git_id) + $DDB["select t2.id as rpmid, t2.rpmname, t1.reponame as repoid, t4.id as builid, t4.proj_id as prjid, t4.create_at from repos as t1 join rpms as t2 on t2.repo_id = t1.id join build_rpm as t3 on t3.rpm_id = t2.id join buildtask as t4 on t4.id = t3.build_id where t1.id = ? and t2.savepath not like '%.src.rpm' order by t4.create_at, t2.rpmname", git_id.to_i].all + end end diff --git a/config.ini b/config.ini index c45fcdd..9fbffe9 100644 --- a/config.ini +++ b/config.ini @@ -14,4 +14,7 @@ path = "locks/counter" [configs] hide=open,amazon,anolis,circle,custom,euro,fedora,mageia,navy,alma,rocky -selected=msvsphere \ No newline at end of file +selected=msvsphere + +[pages] +items_per_page = 30 \ No newline at end of file diff --git a/views/index.erb b/views/index.erb index 4f05d54..6d19947 100644 --- a/views/index.erb +++ b/views/index.erb @@ -98,6 +98,14 @@ +
Имя пакета | +Дата создания | +Git репозиторий | +Номер сборки | +Проект | +Информация о пакете | +
---|---|---|---|---|---|
<%= item[:rpmname] %> | +<%= item[:create_at] %> | +<%= item[:repoid] %> | +build#<%= item[:builid] %> | +Перейти к проекту | +Информация о пакете | +