简介:Sonar平台是目前较为流行的静态代码扫描平台,为了便于使用以及自己二次开发,有必要对它的数据库结构进行学习和理解。
如题,目前网络上搜不到相关内容,只能自己慢慢整理,作为资料,以备查询。
=========================================================================================
查询某个月被扫描到的最多的规则:
SELECT i.rule_id,r.name AS rulename,COUNT(*) AS COUNT,FROM_UNIXTIME(i.created_at/1000) AS createtime,
r.Priority,i.severity,r.plugin_name FROM issues i
,rules r WHERE i.rule_id = r.id AND FROM_UNIXTIME(i.created_at/1000) <‘2017-09-01‘ AND FROM_UNIXTIME(i.created_at/1000)> ‘2017-08-01‘
GROUP BY i.rule_id ORDER BY COUNT DESC
=========================================================================================
查询所有项目:
SELECT NAME FROM projects WHERE scope=‘PRJ‘
=========================================================================================
查询当月所有问题以及对应的项目名、作者、rule id、严重级别等信息:
SELECT p.name AS projectname,i.rule_id,i.message,i.author_login,FROM_UNIXTIME(i.created_at/1000) AS createtime,
i.severity FROM issues i,projects p
WHERE p.project_uuid=i.project_uuid AND p.scope=‘PRJ‘
AND FROM_UNIXTIME(i.created_at/1000) <‘2017-09-01‘ AND FROM_UNIXTIME(i.created_at/1000)> ‘2017-08-01‘
ORDER BY rule_id DESC
=========================================================================================
作者原创技术文章,转载请注明出处