Skip to content

Commit

Permalink
Merge pull request #4 from efsny95/master
Browse files Browse the repository at this point in the history
Calendar work
  • Loading branch information
efsny95 committed May 20, 2014
2 parents 3f96d0d + d4bc6f8 commit 41b7c2e
Show file tree
Hide file tree
Showing 3 changed files with 347 additions and 1 deletion.
25 changes: 25 additions & 0 deletions api/controllers/StationsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,31 @@ module.exports = {
});
});
},
getTrucks:function(req,res){
var station_id = req.param('stationId');
googleapis.discover('bigquery', 'v2').execute(function(err, client) {
jwt.authorize(function(err, result) {
if (err) console.log(err);
console.log()
var request = client.bigquery.jobs.query({
kind: "bigquery#queryRequest",
projectId: 'avail-wim',
timeoutMs: '30000'
});
request.body = {};
request.body.query = 'select num_days,count(num_days) as numDay,month,day,class from(select station_id,class,concat(string(year),string(month),string(day)) as num_days, month,day FROM [tmasWIM12.wim2012] where station_id="'+station_id+'" and station_id is not null) group by num_days,month,day,class';
request.body.projectId = 'avail-wim';
console.log(request);
request
.withAuthClient(jwt)
.execute(function(err, response) {
if (err) console.log(err);
console.log(response);
res.json(response);
});
});
});
},

/**
* Overrides for the settings in `config/controllers.js`
Expand Down
10 changes: 9 additions & 1 deletion config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ module.exports.routes = {
headers: 'content-type,X-Requested-With'
}
},

'/stations/byStation/:stationId':{
controller : 'StationsController',
action : 'getTrucks',
cors: {
origin: '*',
methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
headers: 'content-type,X-Requested-With'
}
}


/*
Expand Down
313 changes: 313 additions & 0 deletions map.html

Large diffs are not rendered by default.

0 comments on commit 41b7c2e

Please sign in to comment.