Optimize spiHelperArchiveCase (one-click archiving)#171
Open
mz7-wiki wants to merge 3 commits intoGeneralNotability:developfrom
Open
Optimize spiHelperArchiveCase (one-click archiving)#171mz7-wiki wants to merge 3 commits intoGeneralNotability:developfrom
mz7-wiki wants to merge 3 commits intoGeneralNotability:developfrom
Conversation
Problem: The current implementation of spiHelperArchiveCase is very inefficient. It goes section by section, blanking and archiving each one, spending many seconds on each section. If a particular SPI case has, say, five closed reports that need to be archived, that means we have to generate no less than 10 edits to archive the case and spend the better part of a minute waiting for the script to finish. When SPI is backlogged, these delays quickly pile up. Solution: Instead of going section by section, we can more optimally go through and do a "one-click archive" by grabbing the case page text only once, figuring out which lines need to be archived and which lines should be kept, and then submitting just two edits: one to archive and one to blank the archived sections. Doing this is tremendously more efficient: instead of waiting a minute to archive an SPI case that has many sections, the processing time is now down to just a couple seconds or so.
Had a bug in my optimization which prevents the {{SPI case status|close}}
string from being removed when archiving a case. I didn't notice this at
first because there is some logic in the template which hides it from
view when it is on an archive page.
DatGuy1
added a commit
to DatGuy1/spihelper
that referenced
this pull request
Jan 13, 2026
Inspiration from GeneralNotability/spihelper#171 Closes #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The current implementation of spiHelperArchiveCase is very inefficient. It goes section by section, blanking and archiving each one, spending many seconds on each section. If a particular SPI case has, say, five closed reports that need to be archived, that means we have to generate no less than 10 edits to archive the case and spend the better part of a minute waiting for the script to finish. When SPI is backlogged, these delays quickly pile up.
Solution
Instead of going section by section, we can more optimally go through and do a "one-click archive" by grabbing the case page text only once, figuring out which lines need to be archived and which lines should be kept, and then submitting just two edits: one to archive and one to blank the archived sections. Doing this is tremendously more efficient: instead of waiting a minute to archive an SPI case that has many sections, the processing time is now down to just a couple seconds or so.
Testing
I tested this in a test SPI for a few edits then tried it out for real on a few SPI cases:
Issue
This partially addresses #15 (allowing for archiving multiple sections at once but not closing multiple sections)