/
yql.server.js
executable file
·45 lines (32 loc) · 1.33 KB
/
yql.server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
YUI.add('StatsModelYQL', function(Y, NAME) {
Y.mojito.models[NAME] = {
init: function(config) {
this.config = config;
},
getData: function(params, callback) {
var //yqlTable = 'store://kIfKmDunyT35ymUmFHJw0M',
yqlTable = 'https://raw.github.com/triptych/trib/master/src/yql/github.xml',
query = "use '{table}' as yahoo.awooldri.github.repo; select watchers,forks from yahoo.awooldri.github.repo where id='yql' and repo='yql-tables'",
queryParams = {
table: yqlTable
},
cookedQuery = Y.substitute(query, queryParams);
Y.log("getData called");
Y.log("cookedQuery:" + cookedQuery);
Y.YQL(cookedQuery, Y.bind(this.onDataReturn, this, callback));
},
onDataReturn: function (cb, result) {
Y.log("onDataReturn called");
if (typeof result.error === 'undefined') {
Y.log("result:");
Y.log(result);
var results = result.query.results.json;
Y.log("results.json:");
Y.log(results);
cb(results);
} else {
cb(result.error);
}
}
};
}, '0.0.1', {requires: ['yql', 'substitute']});