From f95af531881d395a01dc80cff1a93c258e679bd0 Mon Sep 17 00:00:00 2001 From: Murali Nandigama Date: Wed, 7 Apr 2010 11:25:28 -0700 Subject: [PATCH] working mysql based topfails site --- unittest-logs/dbschema.py | 2 +- unittest-logs/dbschema.pyc | Bin 1100 -> 1144 bytes unittest-logs/unittest-log.py | 5 ++--- unittest-logs/unittestweb/settings.pyc | Bin 1787 -> 1799 bytes unittest-logs/unittestweb/settings.py~ | 2 +- unittest-logs/unittestweb/viewer/models.py | 2 +- unittest-logs/unittestweb/viewer/models.pyc | Bin 4693 -> 4697 bytes 7 files changed, 5 insertions(+), 6 deletions(-) diff --git a/unittest-logs/dbschema.py b/unittest-logs/dbschema.py index bc45132..67aaf29 100755 --- a/unittest-logs/dbschema.py +++ b/unittest-logs/dbschema.py @@ -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)) diff --git a/unittest-logs/dbschema.pyc b/unittest-logs/dbschema.pyc index f3d84dd4b49ed3fbd933dc11b1cd2a174f16dff3..87f5079d488077618aa758416207e463426e1c13 100644 GIT binary patch delta 31 ncmX@Z@q>f?;wN4%`Q3XqvR5!MPM_SsWIB01qt527Ow$0QlGTr=;X*weSqT34K diff --git a/unittest-logs/unittest-log.py b/unittest-logs/unittest-log.py index 48b36f0..be2e6b1 100755 --- a/unittest-logs/unittest-log.py +++ b/unittest-logs/unittest-log.py @@ -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,)) diff --git a/unittest-logs/unittestweb/settings.pyc b/unittest-logs/unittestweb/settings.pyc index 5bfabf95556481ad54e66b1f1522ced7f17b3c67..c26d17a017e1a10e683a9172f34b9ff148ee1cab 100644 GIT binary patch delta 136 zcmW;BJrcoC7>3a&1y^p|kPz`xQYh?3_coc#d`4kn8|rLCqtMud%07%v!=yRQ`G!mC zp6}pa_ebkCQQ7X+RUgIJUynJIU;{M7ViY)l(r!ncW6YxrOHhu@(F9wdDVCuE%h3#5 Yq7p0EZ&&SAi36I``B*pg%|)Ny522PDhyVZp delta 128 zcmW;BF%rQ*7>40DV`635NLUHlC=_}J(S42PcNX=IqbMCgjAG{HtFZ~~S6PJ1h?KsDyk3~SLGTcU_nXo1zJ!B(in RB8Tnzk`4Ch)m>xu$$#4y8G!%* diff --git a/unittest-logs/unittestweb/settings.py~ b/unittest-logs/unittestweb/settings.py~ index 1fb0629..71c2b47 100755 --- a/unittest-logs/unittestweb/settings.py~ +++ b/unittest-logs/unittestweb/settings.py~ @@ -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 diff --git a/unittest-logs/unittestweb/viewer/models.py b/unittest-logs/unittestweb/viewer/models.py index 0edcea7..ca67484 100755 --- a/unittest-logs/unittestweb/viewer/models.py +++ b/unittest-logs/unittestweb/viewer/models.py @@ -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 diff --git a/unittest-logs/unittestweb/viewer/models.pyc b/unittest-logs/unittestweb/viewer/models.pyc index 20d7cb41a37c4b29114c2322e31f7275cf20095c..cf0b2b59da02cb432491741894f09dba617ffec3 100644 GIT binary patch delta 31 ncmcbra#Mx<;wN6NJBRjcWZ%xuxNGu${%+>P#Kg^>0z6Cr;wN4%>$|%*vTx^S+%|bXfA?lT0d6J$sXYqn