Skip to content

Commit

Permalink
Fix bug where queries sent by the StatsModel were not URL encoded pro…
Browse files Browse the repository at this point in the history
…perly.
  • Loading branch information
laurenwalker committed Dec 13, 2019
1 parent b08470b commit 683e6eb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/js/models/Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
model.set('totalBeginDates', 0);

//Construct a query
var query = decodeURIComponent(model.get('query')) +
var query = model.get('query') +
" AND endDate:[" + model.firstPossibleDate + " TO " + (new Date()).toISOString() + "]" + //Use date filter to weed out badly formatted data
" AND -obsoletedBy:*",
//Get one row only
Expand Down Expand Up @@ -201,7 +201,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
}

//Construct a query
var query = decodeURIComponent(this.get('query')) +
var query = this.get('query') +
//Use date filter to weed out badly formatted data
" AND beginDate:[" + this.firstPossibleDate + " TO " + (new Date()).toISOString() + "]" +
" AND -obsoletedBy:*",
Expand Down Expand Up @@ -258,7 +258,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
var now = new Date();

//Get the latest temporal data coverage year
var query = decodeURIComponent(this.get('query')) +
var query = this.get('query') +
" AND endDate:[" + this.firstPossibleDate + " TO " + now.toISOString() + "]" + //Use date filter to weed out badly formatted data
" AND -obsoletedBy:*";
var rows = 1,
Expand Down Expand Up @@ -328,7 +328,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
var model = this;

//Build the query to get the format types
var query = decodeURIComponent(this.get('query')) + " AND (formatType:METADATA OR formatType:DATA) AND -obsoletedBy:*",
var query = this.get('query') + " AND (formatType:METADATA OR formatType:DATA) AND -obsoletedBy:*",
rows = "2",
group = true,
groupField = "formatType",
Expand Down Expand Up @@ -438,7 +438,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
return;
}

var query = decodeURIComponent(this.get('query')) + " AND formatType:DATA AND -obsoletedBy:*",
var query = this.get('query') + " AND formatType:DATA AND -obsoletedBy:*",
facet = "true",
facetField = "formatId",
facetLimit = "-1",
Expand Down Expand Up @@ -494,7 +494,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],

var model = this;

var query = decodeURIComponent(this.get('query')) + " AND formatType:METADATA AND -obsoletedBy:*",
var query = this.get('query') + " AND formatType:METADATA AND -obsoletedBy:*",
facet = "true",
facetField = "formatId",
facetLimit = "-1",
Expand Down Expand Up @@ -552,7 +552,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],

var now = new Date();

var metadataQuery = decodeURIComponent(model.get('query')) +
var metadataQuery = model.get('query') +
" AND -obsoletedBy:* AND formatType:METADATA";

var firstPossibleUpdate = MetacatUI.nodeModel.isCN(MetacatUI.nodeModel.get("currentMemberNode"))?
Expand Down Expand Up @@ -625,7 +625,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
model.set('firstUpdate', updateDates[0]);
}

var dataQuery = decodeURIComponent(model.get('query')) +
var dataQuery = model.get('query') +
" AND -obsoletedBy:* AND formatType:DATA";

if( model.get("usePOST") ){
Expand Down Expand Up @@ -725,7 +725,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
firstPossibleUpload = firstPossibleUpload.toISOString();

//Get the earliest upload date
var query = decodeURIComponent(this.get('query')) +
var query = this.get('query') +
" AND formatType:(METADATA OR DATA)" + //Weeds out resource maps and annotations
" AND dateUploaded:[" + firstPossibleUpload + " TO " + now.toISOString() + "]" + //Weeds out badly formatted dates
" AND -obsoletes:*", //Only count one version of a revision chain
Expand Down Expand Up @@ -892,7 +892,7 @@ define(['jquery', 'underscore', 'backbone', 'models/LogsSearch'],
var now = new Date();

//The full query
var query = decodeURIComponent(this.get('query')) +
var query = this.get('query') +
//Use date filter to weed out badly formatted data
" AND beginDate:[" + this.firstPossibleDate + " TO " + now.toISOString() + "]" +
" AND -obsoletedBy:*",
Expand Down

0 comments on commit 683e6eb

Please sign in to comment.