我正在尝试根据以下因素生成月度报告
我试图检查声纳数据库中的实体关系,所有表都是独立的。 我不确定从哪个表中获取值以生成报告。
对于以下提示,提到了
提示:
select proj.name as ClassName, -- Class Name for which violation has been found out
proj.long_name as LongName, -- Long Class Name i.e. with package for which violation has been found out
rf.failure_level as ErrorLevel, -- Error level of the violation
rf.message as Violation, -- Cause of Violation
rf.line as LineNumber, -- Line number of the class file
ru.name ViolationName, -- Violation Description
ru.plugin_name PluginType -- Plugin tool by which this error has been detected i.e. findbug, PMD, etc.
-- ,ru.description -- (if violation description is required we can add this column) from projects proj inner join snapshots snap on proj.id = snap.project_id inner join rule_failures rf on rf.snapshot_id = snap.id inner join rules ru on ru.id = rf.rule_id
答案 0 :(得分:11)
我建议使用Sonar REST API来检索统计信息。
开发团队故意不记录数据库模式。这使他们能够进行不会破坏相关报告应用程序的更改。 (显然这不会阻止某人运行SQL查询)
“ resources ”REST API会返回您请求的指标的最新值
“ timemachine ”REST API返回数据的原始CSV转储:
(我的浏览器将方便地启动电子表格以读取CSV数据)
答案 1 :(得分:8)
您可以使用下表获取上述信息。
1)项目,快照,指标和项目措施。其中projects表包含Projects名称。对于每个项目,在快照表中的特定时间段内创建一个快照ID。然后从快照表中获取快照ID并搜索projects_measure表。并使用指标ID搜索descibed属性的值。
select distinct proj.name NAME_OF_PROJ, metric.description Description,
projdesc.value, snap.created_at CREATED_DATE
from projects proj
inner join snapshots snap on snap.project_id=proj.id
inner join (select max(snap2.created_at) as date_of_creation,id from snapshots snap2
where Date(snap2.created_at) in ('2011-12-20','2012-02-21')
and snap2.project_id in (5507,35252,9807,38954,23018,32390)
GROUP BY DAY(snap2.created_at),snap2.project_id ) as Lookup on Lookup.id=snap.id
inner join project_measures projdesc on projdesc.snapshot_id=snap.id
inner join metrics metric on projdesc.metric_id =metric.id
where metric.id in( 1,2...)