Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Database Reset Commands #54

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

galen8183
Copy link
Contributor

@galen8183 galen8183 commented Mar 1, 2022

This PR adds a number of small changes and features to the dbreset scripts.

Overview of all changes:

  • Renamed some variables to be less ambiguous
  • Added timestamp(s) to status messages, including random code expiration and time until reset completion
  • Reduced DB interactions where possible
  • Prevent extra execCC before sending completion message
  • Change embed formatting and wording for more clarity (you can of course easily change this to whatever you think is reasonable)
  • Reduced redundancy, therefore less characters
  • Reformatted some code for better readability
  • Use truthiness instead of comparison operators in some conditional statements
  • Improve random code generation method (using randInt and printf instead of shuffle)

In my testing, this seems to not have any of the known bugs, those being issue #36 and the very recent reports of invalid key errors.

Add relative timestamp to unique code expiry
Move footer text to description
Less ambiguous variable names
Reformat for readability
Improve db interaction efficiency
Minor wording change/fix
Standardize general flow across each script
Provide more information during deletion (estimated time until completion)
More efficient flow between free/premium
Format for better readability
Reduce db interactions where possible
Use $count variable instead of dbCount call to determine whether or not to loop
Above change allows moving this call to delete more entries per CC execution, changed ETA calculation to reflect this
Avoid extra dbDelMultiple calls, previously relied on 0 entries being deleted to stop
@galen8183
Copy link
Contributor Author

I've made a few more changes here, mainly prompted by 9890313.

These changes make the deletetion significantly more efficient, avoiding the extra costly dbCount call each CC execution, and instead uses the existing $count variable.
It also now only deleted entries when there are entries to delete, using a comparison instead of truthiness within range (I figured adding an else branch with break isn't necessary, since it's only going to iterate at most 10 times).

Additionally, I've changed the sdict key casing within the database entry and execdata to be more readable and follow convention.

Unrelated to this PR, you may consider changing the CC to dbresetpattern, since this is what it actually does (dbCount also reflects this, which was previously misdocumented as counting by the key exactly)

@BlackWolfWoof
Copy link
Owner

I saw this but my fluffbutt hasn't come to this yet. Sorry :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants