0

I have a Firebase Queue with ~300k tasks in it. I construct it like so:

const db = getDatabase()
const scrapeQueueRef = db.ref('/queue/taskQueue')
const queue = new Queue(scrapeQueueRef, (data, progress, resolve, reject) => {
   // do things
   resolve()
})

I think the new Queue call is downloading the entire node and keeping it in-memory as workers complete tasks (based on database bandwidth measurements).

Since it's already in memory, is there a way to access the number of tasks remaining in the queue? I'm hoping to avoid re-downloading the entire node with a call to scrapeQueueRef.once(), but I'd like to add # tasks remaining to my logs.

Brandon
  • 7,736
  • 9
  • 47
  • 72

1 Answers1

1

firebase doesn't allow you run counts without downloading the entire node. My suggestion would be to keep a counter somewhere in firebase that you update and you can link too directly.

Mathew Berg
  • 28,625
  • 11
  • 69
  • 90
  • thanks @matthew berg. i know i can't get a count w/o downloading the node (besides using the REST API and setting `shallow:true`), but with the `worker queue`, i think the node is downloaded anyway. so i'm wondering if there's a way to get a count from the queue's data, and thus avoid the double-count. – Brandon Dec 02 '16 at 16:36