Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
extra check for empty query body when creating warmup query
Browse files Browse the repository at this point in the history
this should actually be validated by ES, but on older versions its not and proceeding on creating the warmup query, renders the fetch index warmers useless.
  • Loading branch information
lmenezes committed Mar 26, 2014
1 parent 9f8e767 commit 14f7edb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
34 changes: 19 additions & 15 deletions dist/kopf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2824,21 +2824,25 @@ function WarmupController($scope, $location, $timeout, ConfirmDialogService, Ale
};

$scope.createWarmerQuery=function() {
$scope.editor.format();
if (!isDefined($scope.editor.error)) {
$scope.client.registerWarmupQuery($scope.new_index.name, $scope.new_types, $scope.new_warmer_id, $scope.editor.getValue(),
function(response) {
$scope.updateModel(function() {
$scope.loadIndexWarmers();
AlertService.success("Warmup query successfully registered", response);
});
},
function(error) {
$scope.updateModel(function() {
AlertService.error("Request did not return a valid JSON", error);
});
}
);
if ($scope.editor.getValue().trim().length > 0) {
$scope.editor.format();
if (!isDefined($scope.editor.error)) {
$scope.client.registerWarmupQuery($scope.new_index.name, $scope.new_types, $scope.new_warmer_id, $scope.editor.getValue(),
function(response) {
$scope.updateModel(function() {
$scope.loadIndexWarmers();
AlertService.success("Warmup query successfully registered", response);
});
},
function(error) {
$scope.updateModel(function() {
AlertService.error("Request did not return a valid JSON", error);
});
}
);
}
} else {
AlertService.error("Warmup query body can't be empty");
}
};

Expand Down
34 changes: 19 additions & 15 deletions src/kopf/controllers/warmup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,25 @@ function WarmupController($scope, $location, $timeout, ConfirmDialogService, Ale
};

$scope.createWarmerQuery=function() {
$scope.editor.format();
if (!isDefined($scope.editor.error)) {
$scope.client.registerWarmupQuery($scope.new_index.name, $scope.new_types, $scope.new_warmer_id, $scope.editor.getValue(),
function(response) {
$scope.updateModel(function() {
$scope.loadIndexWarmers();
AlertService.success("Warmup query successfully registered", response);
});
},
function(error) {
$scope.updateModel(function() {
AlertService.error("Request did not return a valid JSON", error);
});
}
);
if ($scope.editor.getValue().trim().length > 0) {
$scope.editor.format();
if (!isDefined($scope.editor.error)) {
$scope.client.registerWarmupQuery($scope.new_index.name, $scope.new_types, $scope.new_warmer_id, $scope.editor.getValue(),
function(response) {
$scope.updateModel(function() {
$scope.loadIndexWarmers();
AlertService.success("Warmup query successfully registered", response);
});
},
function(error) {
$scope.updateModel(function() {
AlertService.error("Request did not return a valid JSON", error);
});
}
);
}
} else {
AlertService.error("Warmup query body can't be empty");
}
};

Expand Down

0 comments on commit 14f7edb

Please sign in to comment.