Reputation: 91
I am aware I should not use the database directly from SonarQube, but this is a one-shot complex thing, and saves me days if I can do it directly from the database.
I need to know the amount of classes per project, where the amount of lines is less than 200. So far no problem creating this in SQL.
Only problem I have: for 2 projects, this information isn't stored at all in the database! In the GUI from SonarQube I can see this measure for each file, but than in the database these files have only 1 measures stored (technical debt).
My guess is that for some strange reasons these measures are calculated on the fly for this project? Could that be? And is there a way to force SonarQube to store proejct measures for each file in the database? I tried with the sonar.analysis.mode=analysis parameter but that didn't work?
Thanks a lot and regards,
Pieter
Upvotes: 2
Views: 1174
Reputation: 91
it was due to the query. this is the right query
SELECT metrics.description, root.name, COUNT(project_measures.metric_id) AS AmountOfFiles,
SUM(CASE WHEN project_measures.value < 200 THEN 1 ELSE 0 END) Less200,
SUM(CASE WHEN ((project_measures.value >= 200) AND (project_measures.value <= 1000)) THEN 1 ELSE 0 END) Between200And1000,
SUM(CASE WHEN project_measures.value > 1000 THEN 1 ELSE 0 END) More1000
FROM project_measures
INNER JOIN metrics on project_measures.metric_id = metrics.id
INNER JOIN snapshots on project_measures.snapshot_id = snapshots.id
INNER JOIN projects root on snapshots.root_project_id = root.id
WHERE metrics.id = '1' /*Line: code lines + comments + blanc lines*/
and root.scope = 'PRJ' /*projects*/
and snapshots.scope = 'FIL'
and root.name like '%' /* '%' to show all projects*/
GROUP BY root.name
Upvotes: 2
Reputation: 789
I am a little bit confused by your question. Are you saying that, when using your SQL queries, you have the results correct for all but 2 projects, whose metrics appear in the SonarQube dashboard?
I suppose the problem cannot come from your SQL queries? Have you been running these 2 projects recently? Try clearing your browser cache?
Regards.
Upvotes: 0