diff --git a/toolviews/__init__.py b/toolviews/__init__.py index 7e6d471..b37c3ed 100644 --- a/toolviews/__init__.py +++ b/toolviews/__init__.py @@ -1,52 +1,46 @@ # -*- coding: utf-8 -*- # # This file is part of Toolviews # # Copyright (C) 2019 Wikimedia Foundation and contributors # All Rights Reserved. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . -import logging - import pymysql.cursors import toolforge -logger = logging.getLogger(__name__) - - def get_hits(date, tool='*'): conn = toolforge.connect( dbname='s53734__toolviews_p', cluster='labsdb', host='tools.db.svc.eqiad.wmflabs', ) try: - with conn.cursor(pymysql.cursors.SSDictCursor) as cur: + with conn.cursor(pymysql.cursors.DictCursor) as cur: sql = ( "SELECT hits, tool " "FROM daily_raw_views " "WHERE request_day = %s " ) params = (date.strftime('%Y-%m-%d'),) if tool != '*': sql += "AND tool = %s " params += (tool,) sql += "ORDER BY hits desc" cur.execute(sql, params) - logger.info(cur._last_executed) - return cur.fetchall_unbuffered() + return cur.fetchall() finally: conn.close()