[#162,refactor][s]: backend fetch method dataset argument is simple JS object not backbone Dataset.
* Helps make Backends simpler and more independent of Model
This commit is contained in:
parent
3f37da089a
commit
dd45991321
@ -12,9 +12,9 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {};
|
||||
// Load data from a URL via the [DataProxy](http://github.com/okfn/dataproxy).
|
||||
my.fetch = function(dataset) {
|
||||
var data = {
|
||||
url: dataset.get('url'),
|
||||
'max-results': dataset.get('size') || dataset.get('rows') || 1000,
|
||||
type: dataset.get('format') || ''
|
||||
url: dataset.url,
|
||||
'max-results': dataset.size || dataset.rows || 1000,
|
||||
type: dataset.format || ''
|
||||
};
|
||||
var jqxhr = $.ajax({
|
||||
url: my.dataproxy_url,
|
||||
|
||||
@ -3,11 +3,14 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
this.recline.Backend.ElasticSearch = this.recline.Backend.ElasticSearch || {};
|
||||
|
||||
(function($, my) {
|
||||
my.fetch = function(dataset) {
|
||||
};
|
||||
|
||||
// ## ElasticSearch Wrapper
|
||||
//
|
||||
// Connecting to [ElasticSearch](http://www.elasticsearch.org/) endpoints.
|
||||
// @param {String} endpoint: url for ElasticSearch type/table, e.g. for ES running
|
||||
// on localhost:9200 with index // twitter and type tweet it would be:
|
||||
// on http://localhost:9200 with index twitter and type tweet it would be:
|
||||
//
|
||||
// <pre>http://localhost:9200/twitter/tweet</pre>
|
||||
//
|
||||
|
||||
@ -12,6 +12,12 @@ this.recline.Backend.GDocs = this.recline.Backend.GDocs || {};
|
||||
// Dataset must have a url attribute pointing to the Gdocs or its JSON feed e.g.
|
||||
// <pre>
|
||||
// var dataset = new recline.Model.Dataset({
|
||||
// url: 'https://docs.google.com/spreadsheet/ccc?key=0Aon3JiuouxLUdGlQVDJnbjZRSU1tUUJWOUZXRG53VkE#gid=0'
|
||||
// },
|
||||
// 'gdocs'
|
||||
// );
|
||||
//
|
||||
// var dataset = new recline.Model.Dataset({
|
||||
// url: 'https://spreadsheets.google.com/feeds/list/0Aon3JiuouxLUdDQwZE1JdV94cUd6NWtuZ0IyWTBjLWc/od6/public/values?alt=json'
|
||||
// },
|
||||
// 'gdocs'
|
||||
@ -22,10 +28,9 @@ this.recline.Backend.GDocs = this.recline.Backend.GDocs || {};
|
||||
//
|
||||
// * fields: array of Field objects
|
||||
// * records: array of objects for each row
|
||||
//
|
||||
my.fetch = function(dataset) {
|
||||
var dfd = $.Deferred();
|
||||
var url = my.getSpreadsheetAPIUrl(dataset.get('url'));
|
||||
var url = my.getSpreadsheetAPIUrl(dataset.url);
|
||||
$.getJSON(url, function(d) {
|
||||
result = my.parseData(d);
|
||||
var fields = _.map(result.fields, function(fieldId) {
|
||||
|
||||
@ -79,7 +79,7 @@ my.Dataset = Backbone.Model.extend({
|
||||
var dfd = $.Deferred();
|
||||
// TODO: fail case;
|
||||
if (this.backend !== recline.Backend.Memory) {
|
||||
this.backend.fetch(this).then(handleResults)
|
||||
this.backend.fetch(this.toJSON()).then(handleResults)
|
||||
} else {
|
||||
// special case where we have been given data directly
|
||||
handleResults({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user