Skip to content

Optimize spiHelperArchiveCase (one-click archiving)#171

Open
mz7-wiki wants to merge 3 commits intoGeneralNotability:developfrom
mz7-wiki:mz7-develop-oneclickarchive-optimize
Open

Optimize spiHelperArchiveCase (one-click archiving)#171
mz7-wiki wants to merge 3 commits intoGeneralNotability:developfrom
mz7-wiki:mz7-develop-oneclickarchive-optimize

Conversation

@mz7-wiki
Copy link
Copy Markdown

@mz7-wiki mz7-wiki commented Dec 5, 2025

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:

  • Archiving one closed case: blank, archive
  • Archiving multiple closed cases at once: blank, archive
  • Archiving with a mix of open and closed cases:
  • Creating a brand new archive (i.e. where the archive page did not exist beforehand): blank, archive
  • Moving archive to archive of archive if transclusion limit is reached: move log

Issue

This partially addresses #15 (allowing for archiving multiple sections at once but not closing multiple sections)

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.
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.

1 participant