-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.js
More file actions
47 lines (40 loc) · 1.54 KB
/
service.js
File metadata and controls
47 lines (40 loc) · 1.54 KB
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
46
47
var db = require('./db');
var uberBook = require('./uber_book');
module.exports.getTrackInfo = function(callback) {
uberBook.requestCurrent(function(error, currentResponse){
console.log("current response " + currentResponse);
var lat = "";
var long = "";
if(!error) {
console.log("inside");
if(currentResponse.status == 'in_progress') {
lat = currentResponse.destination.latitude;
long = currentResponse.destination.longitude;
}
var api_response = {};
db.get_active_location(function(err, latLongInfo) {
if (!err && (latLongInfo && latLongInfo.length)) {
var id = "";
for (var i in latLongInfo) {
id = latLongInfo[i].id;
lat = latLongInfo[i].loc.split(",")[0].trim();
long = latLongInfo[i].loc.split(",")[1].trim();
}
db.expire_location(id, function (err, response) {
if(!err) {
api_response.lat = lat;
api_response.long = long;
}
callback(null, api_response);
});
} else {
api_response.lat = lat;
api_response.long = long;
callback(null, api_response);
}
});
} else {
callback(true);
}
});
}