From 8ec6707548c8d97b0487664cd9720598cf9da2ae Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 19 May 2015 16:31:36 +0500 Subject: [PATCH] [#247] monitoring page: fix double request + add index --- .../angularjs/build_lists/build_lists_controller.js.erb | 7 ++++++- .../20150519032855_add_updated_at_index_to_build_list.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20150519032855_add_updated_at_index_to_build_list.rb diff --git a/app/assets/javascripts/angularjs/build_lists/build_lists_controller.js.erb b/app/assets/javascripts/angularjs/build_lists/build_lists_controller.js.erb index 89dc8a224..6ce776bca 100644 --- a/app/assets/javascripts/angularjs/build_lists/build_lists_controller.js.erb +++ b/app/assets/javascripts/angularjs/build_lists/build_lists_controller.js.erb @@ -57,6 +57,9 @@ RosaABF.controller('BuildListsController', }, true); $scope.getBuildLists = function() { + if ( $scope.isRequest) { + return; + } // Disable 'Search' button $scope.isRequest = true; @@ -115,6 +118,7 @@ RosaABF.controller('BuildListsController', // Enable 'Search' button $scope.isRequest = false; });; + $scope.first_run = false; } $scope.showRelated = function(build_list, disable_effect) { @@ -144,11 +148,11 @@ RosaABF.controller('BuildListsController', $scope.refresh = function(force) { if ($('#autoreload').is(':checked') || force) { var params = {}; + _.each($("#monitoring_filter").serializeArray(), function(a){ if (a.value) { params[a.name] = a.value; } }); $location.search(params); - $scope.first_run = false; $scope.getBuildLists(); } if (!force) @@ -163,6 +167,7 @@ RosaABF.controller('BuildListsController', $scope.updateParams = function() { var params = $location.search(); + $scope.params = { page: params.page || 1, per_page: params.per_page || 25, diff --git a/db/migrate/20150519032855_add_updated_at_index_to_build_list.rb b/db/migrate/20150519032855_add_updated_at_index_to_build_list.rb new file mode 100644 index 000000000..cf373c722 --- /dev/null +++ b/db/migrate/20150519032855_add_updated_at_index_to_build_list.rb @@ -0,0 +1,5 @@ +class AddUpdatedAtIndexToBuildList < ActiveRecord::Migration + def change + add_index :build_lists, :updated_at, order: { updated_at: :desc } + end +end diff --git a/db/schema.rb b/db/schema.rb index cdd653967..8886a63ed 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150502145718) do +ActiveRecord::Schema.define(version: 20150519032855) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -155,6 +155,7 @@ ActiveRecord::Schema.define(version: 20150502145718) do t.index ["mass_build_id", "status"], :name => "index_build_lists_on_mass_build_id_and_status" t.index ["project_id", "save_to_repository_id", "build_for_platform_id", "arch_id"], :name => "maintainer_search_index" t.index ["project_id"], :name => "index_build_lists_on_project_id" + t.index ["updated_at"], :name => "index_build_lists_on_updated_at", :order => {"updated_at" => :desc} end create_table "projects", force: true do |t|