Skip to content

Commit

Permalink
Fix dashboard by eid failures
Browse files Browse the repository at this point in the history
  • Loading branch information
adiralashiva8 committed Sep 13, 2020
1 parent 40e449b commit 7c813b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion robotframework_historic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def dashboardRecent(db):
cursor.execute("SELECT Execution_Id, Execution_Total from TB_EXECUTION order by Execution_Id desc LIMIT 2;")
exe_info = cursor.fetchall()

if len(exe_info) == 2:
pass
else:
exe_info = (exe_info[0], exe_info[0])

cursor.execute("SELECT Execution_Pass, Execution_Fail, Execution_Total, Execution_Time from TB_EXECUTION WHERE Execution_Id=%s;" % exe_info[0][0])
last_exe_data = cursor.fetchall()

Expand Down Expand Up @@ -185,6 +190,11 @@ def eid_dashboard(db, eid):
cursor.execute("SELECT Execution_Id, Execution_Total from TB_EXECUTION WHERE Execution_Id <=%s order by Execution_Id desc LIMIT 2;" % eid)
exe_info = cursor.fetchall()

if len(exe_info) == 2:
pass
else:
exe_info = (exe_info[0], exe_info[0])

cursor.execute("SELECT Execution_Pass, Execution_Fail, Execution_Total, Execution_Time from TB_EXECUTION WHERE Execution_Id=%s;" % exe_info[0][0])
last_exe_data = cursor.fetchall()

Expand All @@ -200,7 +210,7 @@ def eid_dashboard(db, eid):
cursor.execute("SELECT ROUND(AVG(Test_Time),2) from TB_TEST WHERE Execution_Id=%s;" % exe_info[0][0])
test_avg_dur_data = cursor.fetchall()

cursor.execute("SELECT b.Suite_Name, a.Suite_Fail, b.Occurence from TB_SUITE a INNER JOIN (Select Suite_Name, Count(Suite_Name) as Occurence From TB_SUITE WHERE Suite_Status = 'FAIL' AND Execution_Id>=%s GROUP BY Suite_Name HAVING COUNT(Suite_Name) > 1) b ON a.Suite_Name = b.Suite_Name WHERE Suite_Status='FAIL' AND Execution_Id=%s ORDER BY b.Occurence DESC, a.Suite_Fail DESC LIMIT 5;" % (exe_info[-1][0], exe_info[0][0]))
cursor.execute("SELECT b.Suite_Name, a.Suite_Fail, b.Occurence from TB_SUITE a INNER JOIN (Select Suite_Name, Count(Suite_Name) as Occurence From TB_SUITE WHERE Suite_Status = 'FAIL' AND Execution_Id IN (%s, %s) GROUP BY Suite_Name HAVING COUNT(Suite_Name) > 1) b ON a.Suite_Name = b.Suite_Name WHERE Suite_Status='FAIL' AND Execution_Id=%s ORDER BY b.Occurence DESC, a.Suite_Fail DESC LIMIT 5;" % (exe_info[-1][0], exe_info[0][0], exe_info[0][0]))
common_failed_suites = cursor.fetchall()

cursor.execute("SELECT COUNT(*) From (SELECT Test_Name, Execution_Id From TB_TEST WHERE Test_Status='FAIL' AND Execution_Id >= %s GROUP BY Test_Name HAVING COUNT(Test_Name) = 1) AS T WHERE Execution_Id=%s" % (exe_info[1][0],exe_info[0][0]))
Expand Down
6 changes: 3 additions & 3 deletions robotframework_historic/templates/dashboardByEid.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1 class="page-title">
</div>
</div>
<div class="col-6 col-sm-4 col-lg-3">
<div class="card" onclick="window.open('./failures/{{exe_info[0][0]}}','mywindow');" style="cursor: pointer;" title="Click to view failures">
<div class="card" onclick="window.open('../failures/{{exe_info[0][0]}}','mywindow');" style="cursor: pointer;" title="Click to view failures">
<div class="card-status card-status-left bg-red"></div>
<div class="card-body p-3 text-center">
{% if (failed_test_dif >= 0) %}
Expand Down Expand Up @@ -147,7 +147,7 @@ <h3 class="card-title">Failure Analysis</h3>
</div>
<div class="col-lg-6 col-xl-4">
<div class="alert alert-primary">
Project Recent Failures <a href="./failures" class="alert-link" target="_blank" style="color:blue"><i class="fe fe-link">PermaLink</i></a>
Project Recent Failures <a href="../failures" class="alert-link" target="_blank" style="color:blue"><i class="fe fe-link">PermaLink</i></a>
</div>
<div class="card">
<div class="card-header">
Expand Down Expand Up @@ -219,7 +219,7 @@ <h3 class="card-title">Top 5 Common Failed Suites</h3>
</table>
</div>
<div class="card-footer text-muted">
* Common suites which are failed in recent and recent-1 executions
* Common suites which are failed in {{exe_info[0][0]}} and {{exe_info[0][0]}}-1 executions
</div>
</div>
</div>
Expand Down

0 comments on commit 7c813b7

Please sign in to comment.