transport-tracker icon indicating copy to clipboard operation
transport-tracker copied to clipboard

Deleting Child in raw-bus-location after 10 seconds

Open Maphila opened this issue 7 years ago • 2 comments

I'm trying to delete child (Trip) in raw-bus location (Firebase) after 10 seconds. But getting errors in code, still learning node js. Any help is much appreciated.

exports.DeleteChild = class { constructor(timeRef, rawBusLocationsRef, cutoff, oldItemsQuery ){ this.timeRef = timeRef; this.rawBusLocationsRef = rawBusLocationsRef; this.cutoff = cutoff; this.oldItemsQuery = oldItemsQuery;

// Change the panel once every ten seconds
this.timeTimerId = setInterval(() => {
  this.deleteChild();
}, 10000);

}

deleteChild(){ this.cutoff = this.timeRef - 10000; this.oldItemsQuery = this.rawBusLocationsRef.orderByChild('timestamp').endAt(this.cutoff); return this.oldItemsQuery.once('value').then((snapshot) => { // create a map with all children that need to be removed const updates = {}; snapshot.forEach(child => {updates[child.key] = null;}); // execute all updates in one go and return the result to end the function return this.rawBusLocationsRef.update(updates); }); }};

and the error is:

/*

  • Error: Query.endAt failed: first argument contains NaN in property 'raw-bus-location' at validateFirebaseData (/home/maphilak/server4r/node_modules/@firebase/database/dist/index.nod e.cjs.js:1443:15) at validateFirebaseDataArg (/home/maphilak/server4r/node_modules/@firebase/database/dist/index. node.cjs.js:1421:5) at Query.endAt (/home/maphilak/server4r/node_modules/@firebase/database/dist/index.node.cjs.js: 4985:9) at exports.DeleteChild.deleteChild (/home/maphilak/server4r/delete_child.js:23:74) at Timeout.timeTimerId.setInterval [as _onTimeout] (/home/maphilak/server4r/delete_child.js:16:
  1. at ontimeout (timers.js:475:11) at tryOnTimeout (timers.js:310:5) at Timer.listOnTimeout (timers.js:270:5) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] main: node main.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] main script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /home/maphilak/.npm/_logs/2018-11-30T10_50_04_443Z-debug.log */

Maphila avatar Nov 30 '18 10:11 Maphila

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

stale[bot] avatar Oct 03 '19 23:10 stale[bot]

Please reprioritize

On Fri, 4 Oct 2019 at 01:04, stale[bot] [email protected] wrote:

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/googlemaps/transport-tracker/issues/58?email_source=notifications&email_token=AJGZA4BLSOHQLGUQDVJJSO3QMZ26BA5CNFSM4GHN2KS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAJ3HPY#issuecomment-538162111, or mute the thread https://github.com/notifications/unsubscribe-auth/AJGZA4ADRD6TLFEUERW5IBTQMZ26BANCNFSM4GHN2KSQ .

--

swazidata.com/ https://www.swazidata.com/

Maphila Kunene Founder

[email protected] | [email protected] [email protected] (+268) 78045311 <+26878045311> |

P.O. Box 1448, Matsapha, Kingdom of Swaziland, M202 Royal Science Technoogy Park, Phocweni, Swaziland https://www.google.com/maps/place/RSTP+Innovation+Park/@-26.5084138,31.3345437,2724m/data=!3m1!1e3!4m5!3m4!1s0x1eef492368aecef1:0x87c9571185a2dc66!8m2!3d-26.5130655!4d31.3362667

Maphila avatar Oct 04 '19 09:10 Maphila