LinsaneFC / RasenBot

3 stars 0 forks source link

Implemented MongoDB Integration and Activity Time Tracking #24

Closed benjaminl4917 closed 1 year ago

benjaminl4917 commented 1 year ago

Can I get some suggestions with what the best way is to initialize/grab the correct MongoDB collection(which contains the dictionary with already saved user-tracked data" corresponding to its server name. Currently, I have made it so that if the bot is added to a new server, a new collection is created under the database Rasenbot with the name(ex: "Rasenbot Testing Server"). And if the collection is already under the database then I grab the data/document from there. Right now I have it so that I'm able to get the correct server's name once someone starts an activity and from there grab the server's name through the discord.Member. I don't know if thats acceptable for now but I think there must be a better way. The commented-out on_ready function was an attempt to grab the server name on_ready but I believe it doesn't work as intended. Idk maybe I'm trolling and I don't know how to get the server name another way. Also, I believe that we shouldn't be connecting to the MongoDB collection directly from the displayinfo.py but that is up to discussion.

LinsaneFC commented 1 year ago

In replying to original PR summary... I think there is almost definitely a way to know the server name just because the bot is also in the server. If so, we don't need to look for the person's server but rather the bot itself where it was added. Might need to look into this a little.

benjaminl4917 commented 1 year ago

In replying to original PR summary... I think there is almost definitely a way to know the server name just because the bot is also in the server. If so, we don't need to look for the person's server but rather the bot itself where it was added. Might need to look into this a little.

There is a way to get all the server names that the bot is in. But I don't know how to identify which one I need ifykwim.

LinsaneFC commented 1 year ago

This PR might be fine for an initial merge since the functionality of tracking time exists but we definitely need to spawn some tickets out of this. In no particular order, please make these tickets and assign them either to yourselves to discuss who should take over.

  1. Where are we running mongoDB? Create ticket to find a solution. Local machine? In the cloud? Can we get something for free?
  2. Depends on number 1: Secrets generation with github integration. Perhaps we can use this to store the mongodb URL? Don't need a secrets file that we pass around but instead we'll put our secrets into github.
  3. Moving connection out of this file and to elsewhere. Start the connection to mongoDB elsewhere especially if we have other cogs in the future that will use database.
  4. Cleaning up/offering more with the output. Can we also have days?
  5. Graphs and output of leaderboards and comparisons between members.
  6. Need to update our terms/conditions/rules that this is a feature and to use it we have to turn on activity. On top of that, they allow for their activity to be tracked.
  7. Perhaps need an ability to not load certain cogs if servers don't like the fact that activities are being tracked and they want to use other features but not certain ones.
  8. Further down the future: We may need to look into time zones. Having the bot determine the time zone will end up with discrepancies with what people see in other time zones and the time will be off. Perhaps we use PST or UTC as the "normal" time and we can display their statistics to them based on their own time (after we do some conversions).
  9. We need to keep track of the above suggestions that were not addressed. This includes using defaultdict, updating certain commands for readability, updating a wiki, etc. Some of the smaller things can be addressed in this PR and others can be deferred but should be tracked into issues. Please keep track of this so that it is not forgotten.
  10. Address possibilities of failure where the bot could crash/be offline and how we will track what we can (to the best of our ability) but we should not have incorrect tracking (IE: bot goes offline for a couple of days which ends up with someone's activity time being for multiple days)

@benjaminl4917 since this is your ticket, please make these things into tickets and write a description explaining the need and what we want to be done. Also discuss with the team who wants to work on what and what the plan is for this feature moving forward. since you worked on this feature, you'll own this particular topic.