arv: refactor AN3 report generation #2121
Open
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.
This is part of a set of patches to implement the preview functionality described in #671.
No functionality has changed here - the only change is a refactor of the AN3 reporting logic to keep data validation and wikitext generation in its own method, and posting in the main 'evaluate' function, similar to AIV, UAA, and SPI. Previously, this was spread between evaluate() and another method, without any specific responsibility given to the other method as far as I am able to tell.
Unrelated to this patch, but not sure where else would be an appropriate venue because I don't know the expected behavior: the logic for filling the |orig= parameter in the report template seems to be broken (both before my change and after, I think). I would have fixed it but frankly I don't really understand what should go into that parameter in the first place. The API call does not seem to be parsed properly (the following is from the current version in the master branch as of writing):
twinkle/modules/twinklearv.js
Lines 866 to 906 in 321fb37
It appears as if the
data
parameter of the callback is being used as if it were an array, but it isn't one - it's actually the entire API response object. I think addingdata = data.query.pages[data.query.pageids[0]].revisions;
before line 889 in the callback above would convert it to the array it thinks it's dealing with, but I really have no idea what the actual goal is so I can't figure out whether or not that's correct. I tried looking inside the prefill that gets used by the "create a new report" button at AN3 for instructions, but honestly cannot figure out what "In the section below, link to a version from before all the reverting took place, and which proves the diffs are reverts by showing material the same or similar to what is being reverted to." means, especially considering 3RR applies to not just the same revert 3 times but any 3 reverts on the same page. The template diff2 that is used in that code snippet doesn't even seem to be used correctly (the second parameter being passed is a timestamp, but the documentation says it is for a section heading). If someone is able to clarify the expected behavior or clarify exactly what should go inside the "Previous version reverted to" field in reports at AN3 (they all seem conspicuously empty when I look at AN3), I can probably fix it.