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

arv: refactor AN3 report generation #2121

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

Conversation

TollensWP
Copy link
Contributor

@TollensWP TollensWP commented Dec 9, 2024

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):

new mw.Api().get({
action: 'query',
prop: 'revisions',
format: 'json',
rvprop: 'sha1|ids|timestamp|comment',
rvlimit: 100, // intentionally limited
rvstartid: minid,
rvexcludeuser: params.uid,
indexpageids: true,
titles: params.page
}).done((data) => {
Morebits.wiki.addCheckpoint(); // prevent notification events from causing an erronous "action completed"
// In case an edit summary was revdel'd
const hasHiddenComment = function(rev) {
if (!rev.comment && typeof rev.commenthidden === 'string') {
return '(comment hidden)';
}
return '"' + rev.comment + '"';
};
let orig;
if (data.length) {
const sha1 = data[0].sha1;
for (let i = 1; i < data.length; ++i) {
if (data[i].sha1 === sha1) {
orig = data[i];
break;
}
}
if (!orig) {
orig = data[0];
}
}
let origtext = '';
if (orig) {
origtext = '{{diff2|' + orig.revid + '|' + orig.timestamp + '}} ' + hasHiddenComment(orig);
}

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 adding data = 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.

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

Successfully merging this pull request may close these issues.

1 participant