Skip to content

Commit 17bf654

Browse files
committed
[SERVER-1693] Fixed issue with incorrect results when searching by views name and sorting by any other column.
1 parent 9790838 commit 17bf654

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugins/views/api/api.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,10 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
562562

563563
var selOptions = {app_id: params.qstring.app_id, startPos: startPos, dataLength: dataLength, sortby: sortby, sortcol: sortcol, segment: segment, segmentVal: segmentVal, unique: "u", levels: {daily: ["u", "t", "s", "b", "e", "d", "n", "scr"], monthly: ["u", "t", "s", "b", "e", "d", "n", "scr"]}};
564564

565-
if (sortcol === 'name' || params.qstring.sSearch) {
565+
if (sortcol === 'name' || (params.qstring.sSearch && params.qstring.sSearch !== "")) {
566566
selOptions.count_query = {};
567567
var query = [];
568-
if (params.qstring.sSearch) {
568+
if (params.qstring.sSearch && params.qstring.sSearch !== "") {
569569
query = [{$match: {"view": {$regex: params.qstring.sSearch}}}];
570570
selOptions.count_query = {"view": {$regex: params.qstring.sSearch}};
571571
}
@@ -574,7 +574,7 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
574574
query.push({$skip: startPos});
575575

576576
}
577-
if (dataLength !== 0) {
577+
if (dataLength !== 0 && sortcol === 'name') {
578578
query.push({$limit: dataLength});
579579
}
580580
common.db.collection("app_viewsmeta" + params.qstring.app_id).aggregate(query, {allowDiskUse: true}, function(err1, res) {

0 commit comments

Comments
 (0)