Skip to content
Xin Yang edited this page May 2, 2016 · 4 revisions

Here are some examples about how to query our database.

Query the number of changes by status

Default status in Gerrit includes Merged, Abandoned and New

SELECT COUNT(*), ch_status FROM t_change GROUP BY ch_status;

Query all the review with -2 vote

SELECT * FROM t_history 
WHERE hist_message LIKE '%Do not submit%' 
OR hist_message LIKE '%Code-Review-2%' 
ORDER BY hist_createdTime ASC;

Query all the review with -1 vote

SELECT * FROM t_history 
WHERE hist_message LIKE '%I would prefer that you didn\'t submit this%' 
OR hist_message LIKE '%Code-Review-1%' 
ORDER BY hist_createdTime ASC;

Query all the review with +1 vote

SELECT * FROM t_history 
WHERE hist_message LIKE '%Looks good to me, but someone else must approve%' 
OR hist_message LIKE '%Code-Review+1%' 
ORDER BY hist_createdTime ASC;

Query all the review with +2 vote

(note: some projects have different rules about patch approvals)

SELECT * FROM t_history 
WHERE hist_message LIKE '%Looks good to me, approved%' 
OR hist_message LIKE '%Code-Review+2%' 
ORDER BY hist_createdTime ASC;

Query all the core reviewers

Here we define the core reviewers as the reviewers who voted +2 or -2

SELECT distinct hist_authorId FROM t_history 
WHERE hist_message LIKE '%Looks good to me, approved%' 
OR hist_message LIKE '%Code-Review+2%'
OR hist_message LIKE '%Do not submit%' 
OR hist_message LIKE '%Code-Review-2%'
ORDER BY hist_createdTime ASC;

Clone this wiki locally