def get_latest_release(src="testcase"): cursor = getConnection().cursor() q = """ SELECT release.name FROM release, {} WHERE {}.releaseid = release.id GROUP BY release.name ORDER BY release.name DESC limit 1 """ q = q.format(src, src) rel = cursor.execute(q).fetchone()[0] return rel
def get_executive_results(category): cursor = getConnection().cursor() q = """SELECT component.name as product, release.name as release, SUM(CASE WHEN status = 'fail' THEN 1 ELSE 0 END) as fail, SUM(CASE WHEN status = 'pass' THEN 1 ELSE 0 END) as pass, COUNT(*) as total FROM component, release, category, testcase WHERE testcase.componentid=component.id AND testcase.releaseid=release.id AND testcase.categoryid=category.id AND category.name='{}' GROUP BY release.name, component.name ORDER BY release.name DESC; """ q = q.format(category) rows = cursor.execute(q) results = [ dict(product=row[0], release=row[1], failures=row[2], passed=row[3], total=row[4]) for row in rows.fetchall() ] return results
def dashboard_results(category, release, limit=5): """Last n build results(failed, passed, total) for specified release and category(smoke/regression)""" q = """ SELECT build.name as build, release.name as release, SUM(CASE WHEN status = 'fail' THEN 1 ELSE 0 END) as fail, SUM(CASE WHEN status = 'pass' THEN 1 ELSE 0 END) as pass, COUNT(*) as total FROM build, release, category, testcase, component WHERE testcase.componentid=component.id AND testcase.releaseid=release.id AND testcase.categoryid=category.id AND category.name='{}' AND release.name='{}' AND testcase.buildid = build.id GROUP BY build ORDER BY build.id DESC LIMIT {}; """ q = q.format(category, release, limit) cursor = getConnection().cursor() rows = cursor.execute(q) results = [dict(name=row[0], release=row[1], failed=row[2], passed=row[3], total=row[4]) for row in rows.fetchall()] return results