Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/gsmari/apis into gsmari-master
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanmik committed Dec 1, 2013
2 parents cc36eae + 47d9bcc commit 29ae671
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
36 changes: 26 additions & 10 deletions endpoints/flight/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,37 @@ app.get('/flight', function(req, res){

var obj = { results: []};

var fields = ['date','flightNumber','to','plannedArrival','realArrival','status'];
var fields = ['date','flightNumber','airline','to','plannedArrival','realArrival','status'];

data.find('table tr').each(function(key){
if(key !== 0){
var flight = {
'date': '',
'flightNumber':'',
'to': '',
'plannedArrival': '',
'realArrival': '',
'status': ''
var flight = {};
if(data.type === 'departures') {
flight = {
'date': '',
'flightNumber':'',
'airline':'',
'to': '',
'plannedArrival': '',
'realArrival': '',
'status': ''
}
}
else {
flight = {
'date': '',
'flightNumber':'',
'airline':'',
'from': '',
'plannedArrival': '',
'realArrival': '',
'status': ''
}
}

$(this).find('td').each(function(key){
var val = $(this).html();
if(val != '' && val != 0){ //Perform check and add to car array if it passes
if(val != '' && val != 0){ // Perform check and add to flight array if it passes
flight[fields[key]] = val;

}
Expand All @@ -62,4 +78,4 @@ app.get('/flight', function(req, res){

return res.cache(3600).json(obj);
});
});
});
2 changes: 1 addition & 1 deletion endpoints/flight/tests/integration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var helpers = require('../../../lib/test_helpers.js');

describe('flight', function() {
it("should return an array of objects containing correct fields", function(done) {
var fieldsToCheckFor = ["date","flightNumber","to","plannedArrival","realArrival","status"];
var fieldsToCheckFor = ["date","flightNumber","airline","to","plannedArrival","realArrival","status"];
var params = helpers.testRequestParams("/flight", {
language: "en",
type: "departures"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ describe('endpoint', function() {
done();
});
});
});
});

0 comments on commit 29ae671

Please sign in to comment.