From 778b76e5ff3d428316af5f049d4875a39e910a13 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 18 Jul 2012 14:31:49 +0400 Subject: [PATCH 01/11] [refs #570] Fix mass builds counters update. Fix mass build and failed_build_list links --- app/models/build_list.rb | 4 ++-- app/views/platforms/mass_builds/index.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index a3f0b416b..5c7a151d7 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -106,13 +106,13 @@ class BuildList < ActiveRecord::Base # WTF? around_transition -> infinite loop before_transition do |build_list, transition| - if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status) + if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id end end after_transition do |build_list, transition| - if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status) + if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id end end diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 15ba91f7a..fd5332ec1 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -37,13 +37,13 @@ - @mass_builds.each do |mass_build| %tr %td= mass_build.id - %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id}) + %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}) %td.min_width_120 - MassBuild::COUNT_STATUSES.each do |status| = link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {})) = mass_build.read_attribute "#{status}_count" .both - %td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id), :target => "_blank" if can?(:failed_builds_list, mass_build) + %td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build) %td= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel, mass_build) %td %a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data") From 6430678c00d465a530c57d7cd41a0565c9f718c1 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 18 Jul 2012 16:00:40 +0400 Subject: [PATCH 02/11] [refs #570] Add :all option for build lists visibility --- app/models/ability.rb | 10 +++++----- app/models/build_list/filter.rb | 2 +- app/views/platforms/mass_builds/index.html.haml | 4 ++-- app/views/projects/build_lists/_filter.html.haml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index c9e9d8ab7..b1ca521e6 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -17,7 +17,7 @@ class Ability can :archive, Project, :visibility => 'open' can :read, Issue, :project => {:visibility => 'open'} can :search, BuildList - can :read, BuildList, :project => {:visibility => 'open'} + can [:read, :all], BuildList, :project => {:visibility => 'open'} can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work can :read, Advisory can(:advisories, Platform) {APP_CONFIG['anonymous_access']} @@ -62,10 +62,10 @@ class Ability can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')} can :remove_user, Project - can [:read, :owned], BuildList, :user_id => user.id - can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} - can [:read, :related], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} - can(:read, BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} + can [:read, :owned, :all], BuildList, :user_id => user.id + can [:read, :related, :all], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} + can [:read, :related, :all], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} + can([:read, :all], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} can([:create, :update], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)} can(:publish, BuildList) do |build_list| diff --git a/app/models/build_list/filter.rb b/app/models/build_list/filter.rb index b6095fc71..6384fb8bc 100644 --- a/app/models/build_list/filter.rb +++ b/app/models/build_list/filter.rb @@ -62,7 +62,7 @@ class BuildList::Filter :mass_build_id => nil })) - @options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'index' : 'owned') + @options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'all' : 'owned') @options[:status] = @options[:status].present? ? @options[:status].to_i : nil @options[:created_at_start] = build_date_from_params(:created_at_start, @options) @options[:created_at_end] = build_date_from_params(:created_at_end, @options) diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index fd5332ec1..3f90ab6ee 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -37,10 +37,10 @@ - @mass_builds.each do |mass_build| %tr %td= mass_build.id - %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}) + %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'all'}) %td.min_width_120 - MassBuild::COUNT_STATUSES.each do |status| - = link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {})) + = link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'all'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {})) = mass_build.read_attribute "#{status}_count" .both %td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build) diff --git a/app/views/projects/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml index 0d7d38eaa..883828c8f 100644 --- a/app/views/projects/build_lists/_filter.html.haml +++ b/app/views/projects/build_lists/_filter.html.haml @@ -31,7 +31,7 @@ .lefter= t("layout.build_lists.ownership.related") .both .table - .lefter= f.radio_button :ownership, 'index', :class => 'niceRadio', :id => 'myradio3' + .lefter= f.radio_button :ownership, 'all', :class => 'niceRadio', :id => 'myradio3' .lefter= t("layout.build_lists.ownership.index") .both %br From 70616961007a9c1e6d7b3f8d0454da33397cd87a Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 18 Jul 2012 17:49:21 +0400 Subject: [PATCH 03/11] [refs #570] Replace :all to :everything for builds filter --- app/models/ability.rb | 10 +++++----- app/models/build_list/filter.rb | 2 +- app/views/platforms/mass_builds/index.html.haml | 4 ++-- app/views/projects/build_lists/_filter.html.haml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index b1ca521e6..062eb05f6 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -17,7 +17,7 @@ class Ability can :archive, Project, :visibility => 'open' can :read, Issue, :project => {:visibility => 'open'} can :search, BuildList - can [:read, :all], BuildList, :project => {:visibility => 'open'} + can [:read, :everything], BuildList, :project => {:visibility => 'open'} can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work can :read, Advisory can(:advisories, Platform) {APP_CONFIG['anonymous_access']} @@ -62,10 +62,10 @@ class Ability can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')} can :remove_user, Project - can [:read, :owned, :all], BuildList, :user_id => user.id - can [:read, :related, :all], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} - can [:read, :related, :all], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} - can([:read, :all], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} + can [:read, :owned, :everything], BuildList, :user_id => user.id + can [:read, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} + can [:read, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} + can([:read, :everything], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} can([:create, :update], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)} can(:publish, BuildList) do |build_list| diff --git a/app/models/build_list/filter.rb b/app/models/build_list/filter.rb index 6384fb8bc..05408cb85 100644 --- a/app/models/build_list/filter.rb +++ b/app/models/build_list/filter.rb @@ -62,7 +62,7 @@ class BuildList::Filter :mass_build_id => nil })) - @options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'all' : 'owned') + @options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'everything' : 'owned') @options[:status] = @options[:status].present? ? @options[:status].to_i : nil @options[:created_at_start] = build_date_from_params(:created_at_start, @options) @options[:created_at_end] = build_date_from_params(:created_at_end, @options) diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 3f90ab6ee..e1115e0fa 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -37,10 +37,10 @@ - @mass_builds.each do |mass_build| %tr %td= mass_build.id - %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'all'}) + %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}) %td.min_width_120 - MassBuild::COUNT_STATUSES.each do |status| - = link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'all'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {})) + = link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {})) = mass_build.read_attribute "#{status}_count" .both %td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build) diff --git a/app/views/projects/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml index 883828c8f..5c8071a8e 100644 --- a/app/views/projects/build_lists/_filter.html.haml +++ b/app/views/projects/build_lists/_filter.html.haml @@ -31,7 +31,7 @@ .lefter= t("layout.build_lists.ownership.related") .both .table - .lefter= f.radio_button :ownership, 'all', :class => 'niceRadio', :id => 'myradio3' + .lefter= f.radio_button :ownership, 'everything', :class => 'niceRadio', :id => 'myradio3' .lefter= t("layout.build_lists.ownership.index") .both %br From 94456e6319c895bcb66b9a59e6399ea56d6a0931 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 18 Jul 2012 18:13:37 +0400 Subject: [PATCH 04/11] [refs #570] Replace :index to :everything into specs --- spec/controllers/projects/build_lists_controller_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/controllers/projects/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb index 1431004eb..e52beb320 100644 --- a/spec/controllers/projects/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -125,7 +125,7 @@ describe Projects::BuildListsController do end it 'should show only accessible build_lists' do - get :index, :filter => {:ownership => 'index'} + get :index, :filter => {:ownership => 'everything'} assigns(:build_lists).should include(@build_list1) assigns(:build_lists).should_not include(@build_list2) assigns(:build_lists).should include(@build_list3) @@ -210,7 +210,7 @@ describe Projects::BuildListsController do end it 'should show only accessible build_lists' do - get :index, :filter => {:ownership => 'index'} + get :index, :filter => {:ownership => 'everything'} assigns(:build_lists).should include(@build_list1) assigns(:build_lists).should_not include(@build_list2) assigns(:build_lists).should include(@build_list3) @@ -297,14 +297,14 @@ describe Projects::BuildListsController do it 'should filter by project_name' do # Project.where(:id => build_list2.project.id).update_all(:name => 'project_name') - get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'index'} + get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'everything'} assigns[:build_lists].should_not include(@build_list1) assigns[:build_lists].should include(@build_list2) assigns[:build_lists].should_not include(@build_list3) end it 'should filter by project_name and start_date' do - get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'index', + get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'everything', "created_at_start(1i)" => @build_list3.created_at.year.to_s, "created_at_start(2i)" => @build_list3.created_at.month.to_s, "created_at_start(3i)" => @build_list3.created_at.day.to_s} From 71fc19edc8ebc8b638c2d1d413c0eb638ccd7e9c Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 18 Jul 2012 23:04:26 +0400 Subject: [PATCH 05/11] [refs #570] Change localization for fields --- config/locales/models/build_list.en.yml | 2 +- config/locales/models/build_list.ru.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index cdcf7530e..20d1177fa 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -80,7 +80,7 @@ en: header: Build list ownership owned: My related: Related - index: All + everything: All build_server_status: header: Build server status diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 5c5820a9d..09dd8ef46 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -79,7 +79,7 @@ ru: header: Принадлежность заданий owned: Мне related: Связанные со мной - index: Все + everything: Все build_server_status: header: Статус сборочного сервера From 1f0887ac97e8eb979993443521ab87300bc0d172 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 18 Jul 2012 23:26:13 +0400 Subject: [PATCH 06/11] [refs #570] Change localization for fields(part 2) --- app/views/projects/build_lists/_filter.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml index 5c8071a8e..a9ca14988 100644 --- a/app/views/projects/build_lists/_filter.html.haml +++ b/app/views/projects/build_lists/_filter.html.haml @@ -32,7 +32,7 @@ .both .table .lefter= f.radio_button :ownership, 'everything', :class => 'niceRadio', :id => 'myradio3' - .lefter= t("layout.build_lists.ownership.index") + .lefter= t("layout.build_lists.ownership.everything") .both %br = f.submit t("layout.search.header") From f9b217379d16b1921fa931b678876e67d12cd7f5 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 26 Jul 2012 15:45:23 +0400 Subject: [PATCH 07/11] [refs #570] Add mass build counters logs --- app/models/build_list.rb | 5 ++ app/models/counters_log.rb | 4 ++ app/models/mass_build.rb | 1 + .../20120726110848_create_counters_logs.rb | 11 +++++ db/schema.rb | 49 +++++++++++++------ 5 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 app/models/counters_log.rb create mode 100644 db/migrate/20120726110848_create_counters_logs.rb diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 5c7a151d7..f1b1da794 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -9,6 +9,7 @@ class BuildList < ActiveRecord::Base belongs_to :mass_build, :counter_cache => true has_many :items, :class_name => "BuildList::Item", :dependent => :destroy has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy + has_many :counters_logs, :dependent => :destroy UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage] RELEASE_UPDATE_TYPES = %w[security bugfix] @@ -100,6 +101,8 @@ class BuildList < ActiveRecord::Base after_commit :place_build after_destroy :delete_container + after_create lambda { |build_list| build_list.counters_logs.create(:status => build_list.status, :event => "create", :mass_build_id => build_list.mass_build_id) } + @queue = :clone_and_build state_machine :status, :initial => :waiting_for_response do @@ -108,12 +111,14 @@ class BuildList < ActiveRecord::Base before_transition do |build_list, transition| if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + build_list.counters_logs.create(:status => build_list.status, :event => "decrement", :mass_build_id => build_list.mass_build_id) end end after_transition do |build_list, transition| if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + build_list.counters_logs.create(:status => build_list.status, :event => "increment", :mass_build_id => build_list.mass_build_id) end end diff --git a/app/models/counters_log.rb b/app/models/counters_log.rb new file mode 100644 index 000000000..756471ad5 --- /dev/null +++ b/app/models/counters_log.rb @@ -0,0 +1,4 @@ +class CountersLog < ActiveRecord::Base + belongs_to :build_list + belongs_to :mass_build +end diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 8cdc5c0f9..a756afd1b 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -2,6 +2,7 @@ class MassBuild < ActiveRecord::Base belongs_to :platform belongs_to :user has_many :build_lists, :dependent => :destroy + has_many :counters_logs, :dependent => :destroy scope :by_platform, lambda { |platform| where(:platform_id => platform.id) } diff --git a/db/migrate/20120726110848_create_counters_logs.rb b/db/migrate/20120726110848_create_counters_logs.rb new file mode 100644 index 000000000..fdd3f9941 --- /dev/null +++ b/db/migrate/20120726110848_create_counters_logs.rb @@ -0,0 +1,11 @@ +class CreateCountersLogs < ActiveRecord::Migration + def change + create_table :counters_logs do |t| + t.integer :mass_build_id + t.integer :build_list_id + t.string :status + t.string :event + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 88f4b829f..c21808c13 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120719045806) do +ActiveRecord::Schema.define(:version => 20120726110848) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -143,6 +143,15 @@ ActiveRecord::Schema.define(:version => 20120719045806) do t.integer "project_id" end + create_table "counters_logs", :force => true do |t| + t.integer "mass_build_id" + t.integer "build_list_id" + t.string "status" + t.string "event" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "event_logs", :force => true do |t| t.integer "user_id" t.string "user_name" @@ -160,12 +169,12 @@ ActiveRecord::Schema.define(:version => 20120719045806) do end create_table "flash_notifies", :force => true do |t| - t.text "body_ru", :null => false - t.text "body_en", :null => false - t.string "status", :null => false - t.boolean "published", :default => true, :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.text "body_ru" + t.text "body_en" + t.string "status" + t.boolean "published" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "groups", :force => true do |t| @@ -193,6 +202,15 @@ ActiveRecord::Schema.define(:version => 20120719045806) do add_index "issues", ["project_id", "serial_id"], :name => "index_issues_on_project_id_and_serial_id", :unique => true + create_table "key_pairs", :force => true do |t| + t.integer "repository_id" + t.integer "user_id" + t.integer "key_id" + t.string "public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "labelings", :force => true do |t| t.integer "label_id", :null => false t.integer "issue_id" @@ -311,27 +329,25 @@ ActiveRecord::Schema.define(:version => 20120719045806) do t.text "description" t.string "ancestry" t.boolean "has_issues", :default => true + t.boolean "has_wiki", :default => false t.string "srpm_file_name" t.string "srpm_content_type" t.integer "srpm_file_size" t.datetime "srpm_updated_at" - t.boolean "has_wiki", :default => false t.string "default_branch", :default => "master" t.boolean "is_package", :default => true, :null => false t.integer "average_build_time", :default => 0, :null => false t.integer "build_count", :default => 0, :null => false end - add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false - create_table "register_requests", :force => true do |t| t.string "name" t.string "email" t.string "token" t.boolean "approved", :default => false t.boolean "rejected", :default => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "interest" t.text "more" end @@ -385,6 +401,7 @@ ActiveRecord::Schema.define(:version => 20120719045806) do t.string "name" t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "password_salt", :default => "", :null => false t.string "reset_password_token" t.datetime "remember_created_at" t.datetime "created_at" @@ -392,8 +409,11 @@ ActiveRecord::Schema.define(:version => 20120719045806) do t.string "uname" t.string "role" t.string "language", :default => "en" - t.datetime "reset_password_sent_at" + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" t.integer "own_projects_count", :default => 0, :null => false + t.datetime "reset_password_sent_at" t.text "professional_experience" t.string "site" t.string "company" @@ -405,9 +425,6 @@ ActiveRecord::Schema.define(:version => 20120719045806) do t.integer "failed_attempts", :default => 0 t.string "unlock_token" t.datetime "locked_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" t.string "authentication_token" t.integer "build_priority", :default => 50 end From 548fb99ebe80a625d123490d6d555807e330f372 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 27 Jul 2012 16:28:08 +0400 Subject: [PATCH 08/11] [refs #570] Try to do counters change into transaction with locking --- app/models/build_list.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index f1b1da794..3de142fcb 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -110,14 +110,20 @@ class BuildList < ActiveRecord::Base # WTF? around_transition -> infinite loop before_transition do |build_list, transition| if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) - MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + #MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + MassBuild.transaction do + MassBuild.lock(true).decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + end build_list.counters_logs.create(:status => build_list.status, :event => "decrement", :mass_build_id => build_list.mass_build_id) end end after_transition do |build_list, transition| if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) - MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + #MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + MassBuild.transaction do + MassBuild.lock(true).increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + end build_list.counters_logs.create(:status => build_list.status, :event => "increment", :mass_build_id => build_list.mass_build_id) end end From 33e6cdc285a0766cd1dcfc22ef6eb12cea153fe8 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 27 Jul 2012 19:17:07 +0400 Subject: [PATCH 09/11] [refs #570] Remove mass build counters logs and transactions --- app/models/build_list.rb | 15 ++------------- app/models/counters_log.rb | 4 ---- app/models/mass_build.rb | 1 - db/migrate/20120726110848_create_counters_logs.rb | 11 ----------- db/schema.rb | 11 +---------- 5 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 app/models/counters_log.rb delete mode 100644 db/migrate/20120726110848_create_counters_logs.rb diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 3de142fcb..5c7a151d7 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -9,7 +9,6 @@ class BuildList < ActiveRecord::Base belongs_to :mass_build, :counter_cache => true has_many :items, :class_name => "BuildList::Item", :dependent => :destroy has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy - has_many :counters_logs, :dependent => :destroy UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage] RELEASE_UPDATE_TYPES = %w[security bugfix] @@ -101,8 +100,6 @@ class BuildList < ActiveRecord::Base after_commit :place_build after_destroy :delete_container - after_create lambda { |build_list| build_list.counters_logs.create(:status => build_list.status, :event => "create", :mass_build_id => build_list.mass_build_id) } - @queue = :clone_and_build state_machine :status, :initial => :waiting_for_response do @@ -110,21 +107,13 @@ class BuildList < ActiveRecord::Base # WTF? around_transition -> infinite loop before_transition do |build_list, transition| if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) - #MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id - MassBuild.transaction do - MassBuild.lock(true).decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id - end - build_list.counters_logs.create(:status => build_list.status, :event => "decrement", :mass_build_id => build_list.mass_build_id) + MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id end end after_transition do |build_list, transition| if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) - #MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id - MassBuild.transaction do - MassBuild.lock(true).increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id - end - build_list.counters_logs.create(:status => build_list.status, :event => "increment", :mass_build_id => build_list.mass_build_id) + MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id end end diff --git a/app/models/counters_log.rb b/app/models/counters_log.rb deleted file mode 100644 index 756471ad5..000000000 --- a/app/models/counters_log.rb +++ /dev/null @@ -1,4 +0,0 @@ -class CountersLog < ActiveRecord::Base - belongs_to :build_list - belongs_to :mass_build -end diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index a756afd1b..8cdc5c0f9 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -2,7 +2,6 @@ class MassBuild < ActiveRecord::Base belongs_to :platform belongs_to :user has_many :build_lists, :dependent => :destroy - has_many :counters_logs, :dependent => :destroy scope :by_platform, lambda { |platform| where(:platform_id => platform.id) } diff --git a/db/migrate/20120726110848_create_counters_logs.rb b/db/migrate/20120726110848_create_counters_logs.rb deleted file mode 100644 index fdd3f9941..000000000 --- a/db/migrate/20120726110848_create_counters_logs.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateCountersLogs < ActiveRecord::Migration - def change - create_table :counters_logs do |t| - t.integer :mass_build_id - t.integer :build_list_id - t.string :status - t.string :event - t.timestamps - end - end -end diff --git a/db/schema.rb b/db/schema.rb index c21808c13..f39cf11c9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120726110848) do +ActiveRecord::Schema.define(:version => 20120719045806) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -143,15 +143,6 @@ ActiveRecord::Schema.define(:version => 20120726110848) do t.integer "project_id" end - create_table "counters_logs", :force => true do |t| - t.integer "mass_build_id" - t.integer "build_list_id" - t.string "status" - t.string "event" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "event_logs", :force => true do |t| t.integer "user_id" t.string "user_name" From dd13b38da36b928a0d0cf3263679c6438a93e3d2 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 30 Jul 2012 18:49:40 +0400 Subject: [PATCH 10/11] [refs #570] Add status variable --- app/models/build_list.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 5c7a151d7..31985b391 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -106,14 +106,16 @@ class BuildList < ActiveRecord::Base # WTF? around_transition -> infinite loop before_transition do |build_list, transition| - if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) - MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + status = BuildList::HUMAN_STATUSES[build_list.status] + if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status) + MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id end end after_transition do |build_list, transition| - if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(BuildList::HUMAN_STATUSES[build_list.status]) - MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + status = BuildList::HUMAN_STATUSES[build_list.status] + if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status) + MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id end end From 0305976a2764495146cc303ebc4f82827b5f433c Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 31 Jul 2012 12:56:55 +0400 Subject: [PATCH 11/11] [refs #441] Fix schema --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index f39cf11c9..eaf97e8a0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -163,7 +163,7 @@ ActiveRecord::Schema.define(:version => 20120719045806) do t.text "body_ru" t.text "body_en" t.string "status" - t.boolean "published" + t.boolean "published", :default => true t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end