commit/galaxy-central: guerler: Charts: Allow individual chart types to set request limits
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b62ff72c0d87/ Changeset: b62ff72c0d87 User: guerler Date: 2014-06-11 11:52:01 Summary: Charts: Allow individual chart types to set request limits Affected #: 4 files diff -r 66cfcaf35801b8c80491743807ca4d491bfb42e6 -r b62ff72c0d872fd03ed20ffd782a974f7bc0205d config/plugins/visualizations/charts/static/charts/jqplot/common/config.js --- a/config/plugins/visualizations/charts/static/charts/jqplot/common/config.js +++ b/config/plugins/visualizations/charts/static/charts/jqplot/common/config.js @@ -6,6 +6,7 @@ library : 'JqPlot', tag : 'div', keywords : 'default medium', + query_limit : 10000, settings : { separator_label : { title : 'X axis', diff -r 66cfcaf35801b8c80491743807ca4d491bfb42e6 -r b62ff72c0d872fd03ed20ffd782a974f7bc0205d config/plugins/visualizations/charts/static/charts/nvd3/common/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3/common/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3/common/config.js @@ -6,6 +6,7 @@ library : 'NVD3', tag : 'svg', keywords : 'small', + query_limit : 500, settings : { separator_label : { title : 'X axis', diff -r 66cfcaf35801b8c80491743807ca4d491bfb42e6 -r b62ff72c0d872fd03ed20ffd782a974f7bc0205d config/plugins/visualizations/charts/static/charts/tools.js --- a/config/plugins/visualizations/charts/static/charts/tools.js +++ b/config/plugins/visualizations/charts/static/charts/tools.js @@ -12,6 +12,9 @@ var canvas = options.canvas; var app = options.app; + // get request size from chart + request_dictionary.query_limit = chart.definition.query_limit; + // request data var self = this; app.datasets.request(request_dictionary, function() { diff -r 66cfcaf35801b8c80491743807ca4d491bfb42e6 -r b62ff72c0d872fd03ed20ffd782a974f7bc0205d config/plugins/visualizations/charts/static/library/datasets.js --- a/config/plugins/visualizations/charts/static/library/datasets.js +++ b/config/plugins/visualizations/charts/static/library/datasets.js @@ -20,21 +20,84 @@ this.options = Utils.merge(options, this.optionsDefault); }, - // wait + // request handler request: function(request_dictionary, success, error) { - // link this - var self = this; - - // check if column data is requested if (request_dictionary.groups) { - this._get_dataset(request_dictionary.id, function() { - self._get(request_dictionary, success); - }); + this._get_blocks(request_dictionary, success, error); } else { this._get_dataset(request_dictionary.id, success, error) } }, + // multiple request handler + _get_blocks: function(request_dictionary, success, error) { + // query block size + var query_size = this.app.config.get('query_limit'); + + // set range + var query_start = request_dictionary.start || 0; + var query_end = query_start + request_dictionary.query_limit || query_start + this.app.config.get('query_limit'); + + // get query limit + var query_range = Math.abs(query_end - query_start); + if (query_range <= 0) { + console.debug('FAILED - Datasets::request() - Invalid query range.'); + return; + } + + // get number of required queries + var query_number = Math.ceil(query_range / query_size) || 1; + + // get query dictionary template + var query_dictionary_template = $.extend(true, {}, request_dictionary); + + // fetch blocks + var self = this; + function fetch_blocks (query, success, error) { + self._get(query, function() { + // copy values from query into request_dictionary + var done = false; + for (var group_index in request_dictionary.groups) { + // get source/destination + destination_group = request_dictionary.groups[group_index]; + source_group = query.groups[group_index]; + + // check if value fields already exist + if (!destination_group.values) { + destination_group.values = []; + } + + // concat values + destination_group.values = destination_group.values.concat(source_group.values); + + // validate + if (source_group.values.length == 0) { + done = true; + break; + } + } + + // check if for remaining queries + if (--query_number > 0 && !done) { + var start = query.start + query_size; + query = $.extend(true, query_dictionary_template, {start: start}); + fetch_blocks(query, success, error); + } else { + success(); + } + }); + + }; + + // prepare query + var query = $.extend(true, query_dictionary_template, {start: query_start}); + + // get dataset meta data + this._get_dataset(request_dictionary.id, function() { + fetch_blocks(query, success, error); + }); + }, + // get dataset _get_dataset: function(id, success, error) { // check if dataset is available from cache @@ -62,18 +125,14 @@ // get block id _block_id: function (options, column) { - return options.id + '_' + options.start + '_' + options.end + '_' + column; + return options.id + '_' + options.start + '_' + options.start + this.app.config.get('query_limit') + '_' + column; }, // fills request dictionary with data from cache/response _get: function(request_dictionary, callback) { - // set start/end - if (!request_dictionary.start) { - request_dictionary.start = 0; - } - if (!request_dictionary.end) { - request_dictionary.end = this.app.config.get('query_limit'); - } + // set start + request_dictionary.start = request_dictionary.start || 0; + // get column indices var column_list = []; var column_map = {}; @@ -99,7 +158,7 @@ } } - // check length + // check length of blocks not available in cache if (column_list.length == 0) { // fill dictionary from cache this._fill_from_cache(request_dictionary); @@ -115,7 +174,6 @@ var dataset_request = { dataset_id : request_dictionary.id, start : request_dictionary.start, - end : request_dictionary.end, columns : column_list } @@ -161,7 +219,7 @@ // check length if (limit == 0) { - console.debug('FAILED - Datasets::_fill_from_cache() - Invalid range.'); + console.debug('Datasets::_fill_from_cache() - Reached data range limit.'); } // initialize group values @@ -230,17 +288,13 @@ var offset = dataset_request.start ? dataset_request.start : 0; // set limit - var limit = Math.abs(dataset_request.end - dataset_request.start); - var query_limit = this.app.config.get('query_limit'); - if (!limit || limit > query_limit) { - limit = query_limit; - } + var limit = this.app.config.get('query_limit'); // check length var n_columns = 0; if (dataset_request.columns) { n_columns = dataset_request.columns.length; - console.debug('Datasets::_fetch() - Fetching ' + n_columns + ' column(s)'); + console.debug('Datasets::_fetch() - Fetching ' + n_columns + ' column(s) at ' + offset + '.'); } if (n_columns == 0) { console.debug('Datasets::_fetch() - No columns requested'); Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org