From e803e3f26f771b8e424d251951c88892858cb6b1 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 17 Apr 2015 14:28:59 +0300 Subject: cleanup build model --- app/models/build.rb | 13 +------------ app/models/commit.rb | 1 - db/migrate/20150417000045_cleanup_the_build_model.rb | 9 +++++++++ db/schema.rb | 9 +-------- 4 files changed, 11 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20150417000045_cleanup_the_build_model.rb diff --git a/app/models/build.rb b/app/models/build.rb index 3d776ba..da6257a 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -79,7 +79,6 @@ class Build < ActiveRecord::Base new_build.job_id = build.job_id new_build.commit_id = build.commit_id - new_build.ref = build.ref new_build.project_id = build.project_id new_build.save new_build @@ -133,7 +132,7 @@ class Build < ActiveRecord::Base state :canceled, value: 'canceled' end - delegate :sha, :short_sha, :before_sha, + delegate :sha, :short_sha, :before_sha, :ref, to: :commit, prefix: false def trace_html @@ -219,16 +218,6 @@ class Build < ActiveRecord::Base end end - def ref - build_ref = read_attribute(:ref) - - if build_ref.present? - build_ref - else - commit.ref - end - end - def for_tag? if job && job.build_tags true diff --git a/app/models/commit.rb b/app/models/commit.rb index 5f1aa92..6817a9e 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -117,7 +117,6 @@ class Commit < ActiveRecord::Base build.tag_list = job.tag_list build.project_id = project_id build.job = job - build.ref = ref build.save build end diff --git a/db/migrate/20150417000045_cleanup_the_build_model.rb b/db/migrate/20150417000045_cleanup_the_build_model.rb new file mode 100644 index 0000000..1ade714 --- /dev/null +++ b/db/migrate/20150417000045_cleanup_the_build_model.rb @@ -0,0 +1,9 @@ +class CleanupTheBuildModel < ActiveRecord::Migration + def change + remove_column :builds, :push_data + remove_column :builds, :before_sha + remove_column :builds, :ref + remove_column :builds, :sha + remove_column :builds, :tmp_file + end +end diff --git a/db/schema.rb b/db/schema.rb index 65a1032..f16ae4c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,24 +11,19 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150415142013) do +ActiveRecord::Schema.define(version: 20150417000045) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "builds", force: true do |t| t.integer "project_id" - t.string "ref" t.string "status" t.datetime "finished_at" t.text "trace" t.datetime "created_at" t.datetime "updated_at" - t.string "sha" t.datetime "started_at" - t.string "tmp_file" - t.string "before_sha" - t.text "push_data" t.integer "runner_id" t.integer "commit_id" t.float "coverage" @@ -38,10 +33,8 @@ ActiveRecord::Schema.define(version: 20150415142013) do add_index "builds", ["commit_id"], name: "index_builds_on_commit_id", using: :btree add_index "builds", ["project_id", "commit_id"], name: "index_builds_on_project_id_and_commit_id", using: :btree - add_index "builds", ["project_id", "sha"], name: "index_builds_on_project_id_and_sha", using: :btree add_index "builds", ["project_id"], name: "index_builds_on_project_id", using: :btree add_index "builds", ["runner_id"], name: "index_builds_on_runner_id", using: :btree - add_index "builds", ["sha"], name: "index_builds_on_sha", using: :btree create_table "commits", force: true do |t| t.integer "project_id" -- cgit v1.2.1 From 889942fcbbbe44581e33efbb0d62a5fd0e12ab61 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 17 Apr 2015 14:35:36 +0300 Subject: annotate --- app/models/build.rb | 7 +------ app/models/job.rb | 1 + spec/factories/builds.rb | 7 +------ spec/models/build_spec.rb | 7 +------ spec/models/job_spec.rb | 1 + 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/app/models/build.rb b/app/models/build.rb index da6257a..c9f1230 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -4,20 +4,15 @@ # # id :integer not null, primary key # project_id :integer -# ref :string(255) # status :string(255) # finished_at :datetime # trace :text # created_at :datetime # updated_at :datetime -# sha :string(255) # started_at :datetime -# tmp_file :string(255) -# before_sha :string(255) -# push_data :text # runner_id :integer -# coverage :float # commit_id :integer +# coverage :float # commands :text # job_id :integer # diff --git a/app/models/job.rb b/app/models/job.rb index 14cc344..110c96d 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -13,6 +13,7 @@ # build_tags :boolean default(FALSE), not null # job_type :string(255) default("parallel") # refs :string(255) +# deleted_at :datetime # class Job < ActiveRecord::Base diff --git a/spec/factories/builds.rb b/spec/factories/builds.rb index 369f4ee..a722a05 100644 --- a/spec/factories/builds.rb +++ b/spec/factories/builds.rb @@ -4,20 +4,15 @@ # # id :integer not null, primary key # project_id :integer -# ref :string(255) # status :string(255) # finished_at :datetime # trace :text # created_at :datetime # updated_at :datetime -# sha :string(255) # started_at :datetime -# tmp_file :string(255) -# before_sha :string(255) -# push_data :text # runner_id :integer -# coverage :float # commit_id :integer +# coverage :float # commands :text # job_id :integer # diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index de0e0b9..073a215 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -4,20 +4,15 @@ # # id :integer not null, primary key # project_id :integer -# ref :string(255) # status :string(255) # finished_at :datetime # trace :text # created_at :datetime # updated_at :datetime -# sha :string(255) # started_at :datetime -# tmp_file :string(255) -# before_sha :string(255) -# push_data :text # runner_id :integer -# coverage :float # commit_id :integer +# coverage :float # commands :text # job_id :integer # diff --git a/spec/models/job_spec.rb b/spec/models/job_spec.rb index 96221d7..d993139 100644 --- a/spec/models/job_spec.rb +++ b/spec/models/job_spec.rb @@ -13,6 +13,7 @@ # build_tags :boolean default(FALSE), not null # job_type :string(255) default("parallel") # refs :string(255) +# deleted_at :datetime # require 'spec_helper' -- cgit v1.2.1 From ba97b86868c14c7e4e18bada4247f57bd544c837 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 17 Apr 2015 16:01:24 +0300 Subject: fix build status json --- app/controllers/builds_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/builds_controller.rb b/app/controllers/builds_controller.rb index a1cb017..fc9ec18 100644 --- a/app/controllers/builds_controller.rb +++ b/app/controllers/builds_controller.rb @@ -49,7 +49,7 @@ class BuildsController < ApplicationController end def status - render json: @build.to_json(only: [:status, :id, :sha, :coverage]) + render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha) end def cancel -- cgit v1.2.1