working mysql based topfails site

This commit is contained in:
2010-04-07 11:25:28 -07:00
parent 095ed3c3b9
commit f95af53188
7 changed files with 5 additions and 6 deletions

View File

@@ -65,7 +65,7 @@ def CreateDBSchema(conn):
""")
conn.execute("""
CREATE TABLE IF NOT EXISTS tests (buildid INT, name TEXT, description TEXT)
CREATE TABLE IF NOT EXISTS tests (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, buildid INT, name TEXT, description TEXT)
""")
conn.execute("""
CREATE INDEX tests_name ON tests (name(1024))

Binary file not shown.

View File

@@ -141,9 +141,8 @@ def GetOrInsertTree(conn, tree):
table, insert a new row and return the id."""
conn.execute("""SELECT id FROM trees WHERE name = %s""", (tree))
rows = conn.fetchone()
if len(rows) > 0:
return rows[0]
if conn.rowcount > 0:
return conn.lastrowid
# need to insert it
conn.execute("""INSERT INTO trees (name) VALUES (%s)""", (tree,))

View File

@@ -14,7 +14,7 @@ DATABASE_NAME = 'topfailsdb' # Or path to database file if using sql
DATABASE_USER = 'root' # Not used with sqlite3.
DATABASE_PASSWORD = 'mkngama' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '3306' # Set to empty string for default. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name

View File

@@ -75,6 +75,6 @@ class Tests(models.Model):
def get_most_failing_tests():
cursor = connection.cursor()
cursor.execute("select count(*), name from (select builds.id, name from builds inner join tests on builds.id = tests.buildid group by builds.id, name) group by name order by count(*) desc limit 250")
cursor.execute("select count(*), name from (select builds.id, name from builds inner join tests on builds.id = tests.buildid group by builds.id, name) aaa group by name order by count(*) desc limit 250")
for row in cursor:
yield row