The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Current code: User:DannyS712 test/PC bot.js
This isn't a request to review potential changes, but more like a request to review past changes. I recently tried to convert this script to run asynchronously (https://en.wikipedia.org/w/index.php?title=User%3ADannyS712_test%2FPC_bot.js&type=revision&diff=891178202&oldid=891174776) so that categories would be processed one at a time (this script goes through different polluted categories and removes user pages, for Wikipedia:Bots/Requests for approval/DannyS712 bot 11).
I know next-to-nothing about javascript promises, deferred objects, 'await's, etc, and was hoping that someone could tell me if this was the right way to implement my goal (it works, but is it a good way?) or if there is a better method to use.
Thanks, DannyS712
mw.loader.using('mediawiki.util', function() {
$(document).ready(function() {
if (mw.config.get('wgPageName') === "Wikipedia:Database_reports/Polluted_categories") {
mw.loader.getScript('/w/index.php?title=User:DannyS712 test/page.js&action=raw&ctype=text/javascript')
.then(function() {
let caction = mw.util.addPortletLink(
'p-cactions', 'javascript:void(0)', 'Polluted categories', 'ca-polluted', 'TOOLTIP'
);
$(caction).click(function(e) {
e.preventDefault();
Polluted_categories();
});
}, function (e) {
// Script load failed.
mw.log.error(e.message);
});
});
}
);
});
mw.loader.getScript('scripturl?action=raw&ctype=text/javascript').using(callback)
), See Mediawiki:Gadget-morebits.js's Morebits.batchOperation
class. It is used in Twinkle's unlink, batchdelete, batchundelete, etc and it works fast. Basically what it does is take an array of pages, split it into chunks of 50 (count customisable) and send the API requests to the server for dealing with 50 pages at the same time - which is not too many to clog the server and cause the requests to fail, nor too less to take up a lot of time. The status message for each page can also be seen by running Morebits.status.init(some-div-element-to-show-statuses-in)
prior to executing the batch operation. SD0001 (talk) 17:54, 26 June 2019 (UTC)