diff --git a/src/backend/dataproxy.js b/src/backend/dataproxy.js index 8ce7c025..ac3eeab3 100644 --- a/src/backend/dataproxy.js +++ b/src/backend/dataproxy.js @@ -10,6 +10,8 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {}; // ## load // // Load data from a URL via the [DataProxy](http://github.com/okfn/dataproxy). + // + // Returns array of field names and array of arrays for records my.fetch = function(dataset) { var data = { url: dataset.url, @@ -27,32 +29,9 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {}; dfd.reject(results.error); } - // Rename duplicate fieldIds as each field name needs to be - // unique. - var seen = {}; - var fields = _.map(results.fields, function(field, index) { - var fieldId = field; - while (fieldId in seen) { - seen[field] += 1; - fieldId = field + seen[field]; - } - if (!(field in seen)) { - seen[field] = 0; - } - return { id: fieldId, label: field } - }); - - // data is provided as arrays so need to zip together with fields - var records = _.map(results.data, function(doc) { - var tmp = {}; - _.each(results.fields, function(key, idx) { - tmp[key] = doc[idx]; - }); - return tmp; - }); dfd.resolve({ - records: records, - fields: fields, + records: results.data, + fields: results.fields, useMemoryStore: true }); }) diff --git a/test/backend/gdocs.test.js b/test/backend/gdocs.test.js index 08af2919..4846621d 100644 --- a/test/backend/gdocs.test.js +++ b/test/backend/gdocs.test.js @@ -50,13 +50,13 @@ var sample_gdocs_spreadsheet_data = { ], "xmlns$openSearch": "http://a9.com/-/spec/opensearchrss/1.0/", "entry": [ - { - "category": [ { - "term": "http://schemas.google.com/spreadsheets/2006#list", - "scheme": "http://schemas.google.com/spreadsheets/2006" - } - ], + "category": [ + { + "term": "http://schemas.google.com/spreadsheets/2006#list", + "scheme": "http://schemas.google.com/spreadsheets/2006" + } + ], "updated": { "$t": "2010-07-12T18:32:16.200Z" },