-- Files with FIXME/ERR/WARN
select count(*) from source;

-- FIXME/ERR/WARN total counts
select sum(count) as s, type from message, fixmes where message.id=message_id group by type order by s desc;
-- FIXME/ERR/WARN unique messages
select type, count(type) from message group by type;

-- Most prevalent FIXMEs
select count(count) as nr, sum(count) as s, channel, function, text from message, fixmes where type="fixme" and message.id=message_id group by type, channel, function, text order by nr desc limit 10;
-- Most prevalent ERRs
select count(count) as nr, sum(count) as s, channel, function, text from message, fixmes where type="err" and message.id=message_id group by type, channel, function, text order by nr desc limit 10;

-- Most noisy popular FIXME messages
select * from (select sum(count) as s, count(count) as nr, channel, function, text from message, fixmes where type="fixme" and message.id=message_id group by type, channel, function, text) where nr>24 order by s desc limit 10;
-- Most noisy popular ERR messages
select * from (select sum(count) as s, count(count) as nr, channel, function, text from message, fixmes where type="err" and message.id=message_id group by type, channel, function, text) where nr>24 order by s desc limit 10;

-- Most noisy popular FIXME functions
select * from (select sum(count) as s, count(count) as nr, channel, function from message, fixmes where type="fixme" and message.id=message_id group by type, channel, function) where nr>24 order by s desc limit 10;
-- Most noisy popular ERR functions
select * from (select sum(count) as s, count(count) as nr, channel, function from message, fixmes where type="err" and message.id=message_id group by type, channel, function) where nr>24 order by s desc limit 10;

-- Most same FIXME occurrences in a single file
select max(count) as m, count(count) as nr, channel, function, text from message, fixmes where type="fixme" and message.id=message_id group by type, channel, function, text order by m desc limit 10;
-- Most same ERR occurrences in a single file
select max(count) as m, count(count) as nr, channel, function, text from message, fixmes where type="err" and message.id=message_id group by type, channel, function, text order by m desc limit 10;
