Skip to content

Commit

Permalink
get the test to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajari committed Jan 2, 2017
1 parent 5f6a497 commit 0138488
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
16 changes: 12 additions & 4 deletions features/step_definitions/trip.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function () {
json = JSON.parse(res.body);
}

console.log(json);
console.log(JSON.stringify(json));

if (headers.has('status')) {
got.status = json.status.toString();
Expand All @@ -59,7 +59,7 @@ module.exports = function () {
got.source = json.trips[0].source;
}
if (this.queryParams['destination']) {
got.source = json.trips[0].destination;
got.destination = json.trips[0].destination;
}
}

Expand All @@ -85,6 +85,12 @@ module.exports = function () {
})));
trip_durations = all_durations.map( a => a.reduce(add, 0));
}
if(headers.has('distance')) {
var all_distance = json.trips.filter(t => !!t).map(t => t.legs).map(tl => Array.prototype.concat.apply([], tl.map(sl => {
return sl.distance;
})));
trip_distance = all_distance.map( a => a.reduce(add, 0));
}
}

var ok = true,
Expand All @@ -99,9 +105,10 @@ module.exports = function () {
for (var ni=0; ni<sub.length; ni++) {
var node = this.findNodeByName(sub[ni]),
outNode = subTrips[si][ni];
console.log('outNode', outNode, ' node', node, '\n');
if (this.FuzzyMatch.matchLocation(outNode, node)) {
encodedResult += sub[ni];
extendedTarget += sub[ni];
encodedResult += sub[ni]; console.log("encodedResult", encodedResult);
extendedTarget += sub[ni]; console.log("extendedTarget", extendedTarget);
} else {
ok = false;
encodedResult += util.format('? [%s,%s]', outNode[0], outNode[1]);
Expand All @@ -120,6 +127,7 @@ module.exports = function () {
}

got.durations = trip_durations;
got.distance = trip_distance;

for (var key in row) {
if (this.FuzzyMatch.match(got[key], row[key])) {
Expand Down
4 changes: 2 additions & 2 deletions features/testbot/trip.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ Feature: Basic trip planning
| ed |

When I plan a trip I should get
| waypoints | trips | durations |
| a,b,c,d,e | | |
| waypoints | trips | durations | distance |
| a,b,c,d,e | becadb | 11.100000000000001 | 110.4 |


Scenario: Testbot - Trip planning with multiple scc
Expand Down
4 changes: 2 additions & 2 deletions src/engine/plugins/trip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ Status TripPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacad
if (parameters.source > -1 && parameters.destination > -1) {
for (std::size_t r_counter = 0, f_counter = 0;
r_counter < result_table.size(), f_counter < tfse_table_.size();) {
// swap parameters.destination column with to column
if (r_counter % number_of_original_nodes == parameters.destination) {
// swap parameters.destination column with parameters.source column
if (r_counter % number_of_original_nodes == (long) parameters.destination) {
tfse_table_[f_counter - 2] = result_table_[r_counter++];
continue;
}
Expand Down

0 comments on commit 0138488

Please sign in to comment.