@@ -31,6 +31,16 @@ class AFCStatus(Command): | |||||
commands = ["status", "count", "num", "number"] | commands = ["status", "count", "num", "number"] | ||||
hooks = ["join", "msg"] | hooks = ["join", "msg"] | ||||
def setup(self): | |||||
try: | |||||
self.ignore_list = self.config.commands[self.name]["ignoreList"] | |||||
except KeyError: | |||||
try: | |||||
ignores = self.config.tasks["afc_statistics"]["ignoreList"] | |||||
self.ignore_list = ignores | |||||
except KeyError: | |||||
self.ignore_list = [] | |||||
def check(self, data): | def check(self, data): | ||||
if data.is_command and data.command in self.commands: | if data.is_command and data.command in self.commands: | ||||
return True | return True | ||||
@@ -134,9 +144,8 @@ class AFCStatus(Command): | |||||
def count_submissions(self): | def count_submissions(self): | ||||
"""Returns the number of open AFC submissions (count of CAT:PEND).""" | """Returns the number of open AFC submissions (count of CAT:PEND).""" | ||||
# Subtract two for [[Wikipedia:Articles for creation/Redirects]] and | |||||
# [[Wikipedia:Files for upload]], which aren't real submissions: | |||||
return self.site.get_category("Pending AfC submissions").pages - 2 | |||||
minus = len(ignore_list) | |||||
return self.site.get_category("Pending AfC submissions").pages - minus | |||||
def count_redirects(self): | def count_redirects(self): | ||||
"""Returns the number of open redirect submissions. Calculated as the | """Returns the number of open redirect submissions. Calculated as the | ||||
@@ -20,6 +20,7 @@ | |||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
# SOFTWARE. | # SOFTWARE. | ||||
from earwigbot import wiki | |||||
from earwigbot.commands import Command | from earwigbot.commands import Command | ||||
class AFCSubmissions(Command): | class AFCSubmissions(Command): | ||||
@@ -53,7 +54,13 @@ class AFCSubmissions(Command): | |||||
site = self.bot.wiki.get_site() | site = self.bot.wiki.get_site() | ||||
category = site.get_category("Pending AfC submissions") | category = site.get_category("Pending AfC submissions") | ||||
members = category.get_members(limit=number + len(self.ignore_list)) | |||||
urls = [member.url.encode("utf8") for member in members if member.title not in self.ignore_list] | |||||
members = category.get_members(limit=50) | |||||
urls = [] | |||||
for member in members: | |||||
if member.title in self.ignore_list: | |||||
continue | |||||
if member.namespace == wiki.NS_CATEGORY: | |||||
continue | |||||
urls.append(member.url.encode("utf8")) | |||||
pages = ", ".join(urls[:number]) | pages = ", ".join(urls[:number]) | ||||
self.reply(data, "{0} pending AfC subs: {1}".format(number, pages)) | self.reply(data, "{0} pending AfC subs: {1}".format(number, pages)) |
@@ -280,10 +280,10 @@ class AFCStatistics(Task): | |||||
for pageid, title, ns in cursor: | for pageid, title, ns in cursor: | ||||
title = title.decode("utf8").replace("_", " ") | title = title.decode("utf8").replace("_", " ") | ||||
ns = self.site.namespace_id_to_name(ns) | |||||
if ns: | |||||
title = u":".join((ns, title)) | |||||
if title in self.ignore_list: | |||||
ns_name = self.site.namespace_id_to_name(ns) | |||||
if ns_name: | |||||
title = u":".join((ns_name, title)) | |||||
if title in self.ignore_list or ns == wiki.NS_CATEGORY: | |||||
continue | continue | ||||
msg = u"Tracking page [[{0}]] (id: {1})".format(title, pageid) | msg = u"Tracking page [[{0}]] (id: {1})".format(title, pageid) | ||||
self.logger.debug(msg) | self.logger.debug(msg) | ||||