samuelsogbesan / leetbot

LeetCode Question Bot for Discord.
Apache License 2.0
1 stars 0 forks source link

Implement FIFO Queue Methods 🗂️ #10

Closed samuelsogbesan closed 3 years ago

samuelsogbesan commented 3 years ago

Implement the poll and offer methods found in a typical queue. These methods rely on our firebase database for their functionality.

pollPlayer & pollPlayers take the user from the queue on a first-in-first-out basis. The FIFO order is maintained by passing in the creation timestamp as the value for the user. offerPlayerToQueue adds a player to the back of the queue. removePlayerFromQueue removes a player from the queue out of order. To be used, for example, when a player leaves/joins a queue.

holding off on implementing getQueueSize, since there might be some smart ways to do this (such as updating a stored value). Firebase off the bat does not provide a way to query size without querying the entire database table, and I don't think this is sustainable if we hold a lot of data. It's also kind of slow 🥵

(Note to self, this was accompanied by a firebase security rule to allow ordering by value!)