From 241d622856f49f2aaecbadfdc366625e03caf38e Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 5 Jul 2012 22:13:31 -0400 Subject: [PATCH] Fix; apparently I switched API and SQL! --- earwigbot/wiki/category.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/earwigbot/wiki/category.py b/earwigbot/wiki/category.py index f86e935..c069a08 100644 --- a/earwigbot/wiki/category.py +++ b/earwigbot/wiki/category.py @@ -104,6 +104,13 @@ class Category(Page): def _get_size_via_api(self, member_type): """Return the size of the category using the API.""" + result = self.site.api_query(action="query", prop="categoryinfo", + cmtitle=self.title) + info = result["query"]["pages"].values()[0]["categoryinfo"] + return info[member_type] + + def _get_size_via_sql(self, member_type): + """Return the size of the category using SQL.""" query = "SELECT COUNT(*) FROM categorylinks WHERE cl_to = ?" title = self.title.replace(" ", "_").split(":", 1)[1] if member_type == "size": @@ -111,14 +118,7 @@ class Category(Page): else: query += " AND cl_type = ?" result = self.site.sql_query(query, (title, member_type[:-1])) - return list(result)[0] - - def _get_size_via_sql(self, member_type): - """Return the size of the category using SQL.""" - result = self.site.api_query(action="query", prop="categoryinfo", - cmtitle=self.title) - info = result["query"]["pages"].values()[0]["categoryinfo"] - return info[member_type] + return list(result)[0][0] def _get_size(self, member_type): """Return the size of the category."""