Skip to content

Commit

Permalink
specif name strategy wifi
Browse files Browse the repository at this point in the history
  • Loading branch information
JohaoRosasRosillo committed Apr 18, 2022
1 parent db97d52 commit d2cc365
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/agent/providers/geo/strategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function geoip(cb) {
}

var save_data = (data) => {
storage.do('set', {type: 'keys', id: 'geo', data: {value: JSON.stringify(data)}}, (err) => {
if (err) logger.error('Unable to save geo data');
storage.do('set', {type: 'keys', id: 'last_wifi_location', data: {value: JSON.stringify(data)}}, (err) => {
if (err) logger.error('Unable to save last_wifi_location data');
});
}

Expand Down Expand Up @@ -80,7 +80,7 @@ function wifi(cb) {
needle.post(GEO_ENDPOINT, data, opts, function(err, resp, body) {

if (resp.statusCode == 429) {
storage.do('query', {type: 'keys', column: 'id', data: 'geo'}, (err, stored_data) => {
storage.do('query', {type: 'keys', column: 'id', data: 'last_wifi_location'}, (err, stored_data) => {
if (err) return cb(new Error('Unable to read geo data'));
if (stored_data.length == 0) return cb(new Error('There is no geo data in DB'));
else{
Expand Down Expand Up @@ -176,12 +176,12 @@ function wifi(cb) {
method: 'wifi'
};

storage.do('query', {type: 'keys', column: 'id', data: 'geo'}, (err, stored_data) => {
if (err) logger.error('Unable to read geo data');
storage.do('query', {type: 'keys', column: 'id', data: 'last_wifi_location'}, (err, stored_data) => {
if (err) logger.error('Unable to read last_wifi_location data');
if (stored_data.length == 0) save_data(data);
else{
storage.do('del', {type: 'keys', id: 'geo'}, (err) => {
if (err) logger.error('Unable to delete geo data');
storage.do('del', {type: 'keys', id: 'last_wifi_location'}, (err) => {
if (err) logger.error('Unable to delete last_wifi_location data');
save_data(data);
})
}
Expand Down

0 comments on commit d2cc365

Please sign in to comment.