diff --git a/app.rb b/app.rb index 224fc25..159a9cb 100644 --- a/app.rb +++ b/app.rb @@ -980,8 +980,9 @@ get "/buildinfofraw" do if params["file"].nil? || !File.exist?(params["file"]) print_error_page(503, "Файл не найден") else - if !File.binary?(params["file"]) && params["file"].start_with?(File.join(Dir.pwd(), cfg.get_projects_path)) - send_file params["file"] + if File.binary?(params["file"]) && params["file"].start_with?(File.join(Dir.pwd(), cfg.get_projects_path)) + f_name = File.basename(params["file"]) + send_file(params["file"], :filename => f_name, :type => "application/octet-stream", :disposition => 'attachment') else print_error_page(503, "Файл не может быть скачан") end diff --git a/classes/db.rb b/classes/db.rb index 1c2f977..b15bb45 100644 --- a/classes/db.rb +++ b/classes/db.rb @@ -320,7 +320,7 @@ class DBase end def get_builds() - $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc"].all + $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, case when buildstart is null then 0 when buildstop is null then 0 else Cast((JulianDay(buildstop) - JulianDay(buildstart))*24*60*60 As Integer) end as timeproc, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc"].all end def get_build_info(build_id) @@ -341,11 +341,11 @@ class DBase end def get_builds_for_project(prj_id) - $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc", prj_id.to_i].all + $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, case when buildstart is null then 0 when buildstop is null then 0 else Cast((JulianDay(buildstop) - JulianDay(buildstart))*24*60*60 As Integer) end as timeproc,t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc", prj_id.to_i].all end def get_builds_for_project_git(prj_id, git_id) - $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? and t1.repo_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc", prj_id.to_i, git_id.to_i].all + $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, case when buildstart is null then 0 when buildstop is null then 0 else Cast((JulianDay(buildstop) - JulianDay(buildstart))*24*60*60 As Integer) end as timeproc ,t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? and t1.repo_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc", prj_id.to_i, git_id.to_i].all end def delete_git_from_project(prj_id, git_id) @@ -392,4 +392,12 @@ class DBase def cancel_hang_builds() BuildTask.where(result: [0, 3]).update(result: 4) end + + def update_build_task_begin_time(build_id) + BuildTask.where(id: build_id.to_i).update(buildstart: DateTime.now) + end + + def update_build_task_end_time(build_id) + BuildTask.where(id: build_id.to_i).update(buildstop: DateTime.now) + end end diff --git a/classes/mock.rb b/classes/mock.rb index e2fe583..8e9db8a 100644 --- a/classes/mock.rb +++ b/classes/mock.rb @@ -286,6 +286,7 @@ class MockManager end end @db.update_build_task_status(@build_id, 0) + @db.update_build_task_begin_time(@build_id) if @spec == "" @error = true @@ -312,6 +313,7 @@ class MockManager else @db.update_build_task_status(@build_id, 2) end + @db.update_build_task_end_time(@build_id) global_lock.flock(File::LOCK_UN) end diff --git a/db/migrations/202511140000000_create_queue.rb b/db/migrations/202511140000000_create_queue.rb new file mode 100644 index 0000000..e69de29 diff --git a/db/migrations/202511300000000_update.rb b/db/migrations/202511300000000_update.rb new file mode 100644 index 0000000..a1ddd78 --- /dev/null +++ b/db/migrations/202511300000000_update.rb @@ -0,0 +1,12 @@ +require "sequel" + +Sequel.migration do + change do + alter_table(:buildtask) do + add_column :buildstart, DateTime + add_column :buildstop, DateTime + set_column_allow_null :buildstart + set_column_allow_null :buildstop + end + end +end \ No newline at end of file diff --git a/views/buildslist.erb b/views/buildslist.erb index d0bb067..42e4877 100644 --- a/views/buildslist.erb +++ b/views/buildslist.erb @@ -8,6 +8,7 @@ git репозиторий Дата сборки Число собранных пакетов + Время сборки Состояние Перейти к сборке @@ -42,6 +43,7 @@ <%= item[:reponame] %> <%= item[:createat] %> <%= item[:pkgcnt] %> + <%= item[:timeproc] %> сек <%= st %> diff --git a/views/prjbuildslist.erb b/views/prjbuildslist.erb index 96d3cc5..36d2dba 100644 --- a/views/prjbuildslist.erb +++ b/views/prjbuildslist.erb @@ -9,6 +9,7 @@ git репозиторий Дата сборки Число собранных пакетов + Время сборки Состояние Перейти к сборке @@ -43,6 +44,7 @@ <%= item[:reponame] %> <%= item[:createat] %> <%= item[:pkgcnt] %> + <%= item[:timeproc] %> сек <%= st %> diff --git a/views/prjbuildslistgit.erb b/views/prjbuildslistgit.erb index 364d7e4..df33a85 100644 --- a/views/prjbuildslistgit.erb +++ b/views/prjbuildslistgit.erb @@ -9,6 +9,7 @@ git репозиторий Дата сборки Число собранных пакетов + Время сборки Состояние Перейти к сборке @@ -43,6 +44,7 @@ <%= item[:reponame] %> <%= item[:createat] %> <%= item[:pkgcnt] %> + <%= item[:timeproc] %> сек <%= st %>