dvillavicencio / riven-bot

Discord Bot for Destiny 2 that retrieves statistics regarding Raid and Dungeon activities through Discord chat
2 stars 0 forks source link

Raid Stats | Implement Semaphores and Database Authentication #68

Closed dvillavicencio closed 5 months ago

dvillavicencio commented 8 months ago

This iteration of the Raid Stats command implements two important mechanisms. First, we need to implement a way so that there can only be 25 requests to the Bungie.net PGCR endpoint on the fly. In other words, we need to load balance the overall amount of requests that we make to this API. The second mechanism to implement regards how we retrieve raid statistics information for a previously-requested user vs. a non-previously requester user.

Acceptance Criteria a. Implement a mechanism so that the PGCR Bungie client does not exceed 25 requests per second on the fly. b. For requesting data from previously-seen users we need to use the MongoDB database entries to check if the user requested exists. ~One way we can do this is to send in the raid-stats request as a value <user>:<tag>:<membershipId>:<membershipType> as a key.~ Then the following should happen:

  1. If the user exists in the database
    • Then we need to check if there are any recent entries in bungie.net for any recent raids. Given the current instant when the request was sent, check the first page of activities for any non-tracked raids. If the most recent one was after the last Date this user was requested, then load all activities until we find the last-loaded raid. Else, we already have the most up to date raid data for this user, so nothing further to do.
    • Finally update the latest Date when the user was requested
  2. If the user does not exist in the database
    • Then we need to load all the details into the database regarding their raid history, all the activities done in the past and the PGCRs, if they don't exist already, some PGCRs could be shared among users.
    • Update the Date this user was last requested with today