Merge lp:~hjarrell555/ubuntu-qa-website/bug_1366579 into lp:ubuntu-qa-website

Proposed by Hunter
Status: Merged
Merged at revision: 415
Proposed branch: lp:~hjarrell555/ubuntu-qa-website/bug_1366579
Merge into: lp:ubuntu-qa-website
Diff against target: 135 lines (+60/-47)
1 file modified
modules/qatracker/report/qatracker.report.defects.php (+60/-47)
To merge this branch: bzr merge lp:~hjarrell555/ubuntu-qa-website/bug_1366579
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Review via email: mp+281817@code.launchpad.net

Description of the change

Changed the defects report to add sorting to status and importance columns.

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Hunter, I see status and importance are sortable; do you think we could make any field sortable? Should be a trivial enough tweak yes?

I'm having trouble testing this on my local install, so I'll take your word for it that it's tests out a-ok.

Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Needs Information
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Also Hunter, it would be useful if you could writeup / script up using that production db dump on a new instance of the qatracker. Perhaps expand the script to do it? I wiped my old install, and now I'm having trouble recreating what I had you do, hah!

Revision history for this message
Hunter (hjarrell555) wrote :

I only restored the qatracker_launchpad_bug table but I could expand it to the other tables too if you wanted. While I'm at school the command I used was: pg_restore --data-only --table=qatracker_launchpad_bug <datadump> > bugs.pg

Then psql -f bug.pg

I then just created test milestones and series and products like the isodev setup guide and added bug numbers pulled from SELECT bugnumber FROM qatracker_launchpad_bug;

Revision history for this message
Hunter (hjarrell555) wrote :

I only restored the qatracker_launchpad_bug table but I could expand it to the other tables too if you wanted. While I'm at school the command I used was: pg_restore --data-only --table=qatracker_launchpad_bug <datadump> > bugs.pg

Then psql -f bug.pg

I then just created test milestones and series and products like the isodev setup guide and added bug numbers pulled from SELECT bugnumber FROM qatracker_launchpad_bug;

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Ahh, you only restored the specific table. That sounds like a good idea. The full restore doesn't work out so well.

Revision history for this message
Hunter (hjarrell555) wrote :

Yeah when I tried a restore of just the full dumo I broke my install.

Revision history for this message
Hunter (hjarrell555) wrote :

Yeah any table can be sorted the change only has to be done on the header. It just needs a field value with the database field that column represents and a default sort order. Ex:

$header = array(
array('data' => 'Column Name', 'field' => 'databasefield', 'sort' => 'ASC')
);

Also about the database restore I forgot that last night I was going to use the pg_restore to restore just the data from all the qatracker tables and I left it about 20min and it still wasn't finished, so I canceled it.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Hunter, yes, I would just add the sorting for all fields to the header. With that, this has my approval.

416. By Hunter

Added sortability to all columns except bugnumber for defects report

Revision history for this message
Hunter (hjarrell555) wrote :

The only issue is that I couldn't get the bug number to sort. I was getting an error with the tablesort module for the Bug # column.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

LGTM, I will confirm in testing tomorrow.

Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/qatracker/report/qatracker.report.defects.php'
2--- modules/qatracker/report/qatracker.report.defects.php 2012-11-06 21:45:44 +0000
3+++ modules/qatracker/report/qatracker.report.defects.php 2016-01-09 00:57:52 +0000
4@@ -45,53 +45,66 @@
5 return $content;
6 }
7
8-function qatracker_getbugs_for_release($siteid) {
9+function qatracker_getbugs_for_release($siteid, $header) {
10 /*
11 * Get all the bugs for all the milestones of a release
12 * for a given siteid
13 */
14-
15- $result = db_query("
16-SELECT DISTINCT m.title mtitle
17- ,l.bugnumber
18- ,l.product
19- ,l.title btitle
20- ,l.status
21- ,l.importance
22- ,l.assignee
23- ,l.commentscount
24- ,l.duplicatescount
25- ,l.subscriberscount
26- ,m.id
27- ,(CASE
28+ $query = db_select('qatracker_build', 'b')
29+ ->extend('TableSort')
30+ ->extend('PagerDefault');
31+ $query->distinct();
32+ $query->addField('m', 'title', 'mtitle');
33+ $query->fields('l', array(
34+ 'bugnumber',
35+ 'product',
36+ 'title'));
37+ $query->addField('l', 'title', 'btitle');
38+ $query->fields('l', array(
39+ 'status',
40+ 'importance',
41+ 'assignee',
42+ 'commentscount',
43+ 'duplicatescount',
44+ 'subscriberscount'
45+ ));
46+ $query->addField('m', 'id');
47+ $query->addExpression("CASE
48 WHEN l.importance = 'Critical' THEN 0
49 WHEN l.importance = 'High' THEN 1
50 WHEN l.importance = 'Medium' THEN 2
51 WHEN l.importance = 'Low' THEN 3
52 WHEN l.importance = 'Undecided' THEN 10
53- ELSE 5 END
54- ) importance_order
55-FROM qatracker_build b
56-JOIN qatracker_product p ON p.id = b.productid
57-JOIN qatracker_build_milestone bm ON bm.buildid = b.id
58-JOIN qatracker_milestone m ON bm.milestoneid = m.id
59-JOIN qatracker_testsuite_product tp ON tp.productid = b.productid AND tp.milestone_seriesid = m.seriesid
60-JOIN qatracker_testsuite_testcase tt ON tt.testsuiteid = tp.testsuiteid
61-JOIN qatracker_testcase t ON tt.testcaseid = t.id
62-JOIN qatracker_result r ON (r.testcaseid = t.id AND r.buildid = b.id)
63-JOIN qatracker_bug g ON g.resultid = r.id
64-JOIN qatracker_launchpad_bug l ON g.bugnumber = l.originalbug
65-WHERE m.siteid = :siteid
66-AND SUBSTRING(m.title, '^[^ ]+') IN (
67- SELECT DISTINCT SUBSTRING(m2.title, '^[^ ]+')
68- FROM qatracker_milestone m2
69- WHERE m2.status IN (0,1)
70- AND m2.siteid = m.siteid
71-)
72-AND tt.status IN (0, 2)
73-ORDER by m.id DESC, importance_order, l.status", array(":siteid" => intval($siteid)));
74-
75- return $result->fetchAll();
76+ ELSE 5 END", 'importance_order');
77+ $query->join('qatracker_product', 'p', 'p.id = b.productid');
78+ $query->join('qatracker_build_milestone', 'bm', 'bm.buildid = b.id');
79+ $query->join('qatracker_milestone', 'm', 'bm.milestoneid = m.id');
80+ $query->join('qatracker_testsuite_product', 'tp', 'tp.productid = b.productid AND tp.milestone_seriesid = m.seriesid');
81+ $query->join('qatracker_testsuite_testcase', 'tt', 'tt.testsuiteid = tp.testsuiteid');
82+ $query->join('qatracker_testcase', 't', 'tt.testcaseid = t.id');
83+ $query->join('qatracker_result', 'r', '(r.testcaseid = t.id AND r.buildid = b.id)');
84+ $query->join('qatracker_bug', 'g', 'g.resultid = r.id');
85+ $query->join('qatracker_launchpad_bug', 'l', 'g.bugnumber = l.originalbug');
86+ $query->condition('m.siteid', intval($siteid));
87+
88+ $subquery = db_select('qatracker_milestone', 'm2');
89+ $subquery->distinct();
90+ $subquery->addExpression("SUBSTRING(m2.title, '^[^ ]+')");
91+ $or = db_or();
92+ $or->condition('m2.status', 0, '=');
93+ $or->condition('m2.status', 1, '=');
94+ $subquery->condition($or);
95+ $subquery->condition('m2.siteid', 'm.siteid');
96+
97+ $query->addExpression("SUBSTRING(m.title, '^[^ ]+') IN (" . $subquery->__toString() . ')');
98+ $or = db_or();
99+ $or->condition('tt.status', 0, '=');
100+ $or->condition('tt.status', 2, '=');
101+ $query->condition($or);
102+ $query->condition('tt.status', array(0, 2), 'IN');
103+ $query->orderBy('m.id', 'DESC');
104+ $query->orderByHeader($header);
105+ return $query->execute()->fetchAll();
106 }
107
108
109@@ -122,17 +135,17 @@
110
111 $header = array(
112 array('data' => 'Bug #'),
113- array('data' => 'Title'),
114- array('data' => 'Affects'),
115- array('data' => 'Status'),
116- array('data' => 'Importance'),
117- array('data' => 'Assignee'),
118- array('data' => 'Com.'),
119- array('data' => 'Sub.'),
120- array('data' => 'Dup.'),
121+ array('data' => 'Title', 'field' => 'btitle', 'sort' => 'DESC'),
122+ array('data' => 'Affects', 'field' => 'l.product', 'sort' => 'DESC'),
123+ array('data' => 'Status', 'field' => 'l.status', 'sort' => 'DESC'),
124+ array('data' => 'Importance', 'field' => 'l.importance', 'sort' => 'DESC'),
125+ array('data' => 'Assignee', 'field' => 'l.assignee', 'sort' => 'DESC'),
126+ array('data' => 'Com.', 'field' => 'l.commentscount', 'sort' => 'DESC'),
127+ array('data' => 'Sub.', 'field' => 'l.subscriberscount', 'sort' => 'DESC'),
128+ array('data' => 'Dup.', 'field' => 'l.duplicatescount', 'sort' => 'DESC'),
129 );
130
131- $bugs = qatracker_getbugs_for_release($siteid);
132+ $bugs = qatracker_getbugs_for_release($siteid, $header);
133
134 $curr_milestone = "";
135 $rows = array();

Subscribers

People subscribed via source and target branches