How can i get the RCI and Code Coverage number from a Branch by a query in a Sonarqube Database?

127 Views Asked by At

I need some help with Sonarqube Database.

Every month, I'm extracting some indicators from the Sonarqube database as RCI and Coverage. We use Sonar 7.1 and Branch Plugin Community Edition in version 2.0.0.0.

When we execute a select in a sonar database by Branch Master, we retrieve the exactly RCI number and Coverage number showed in Sonarqube Web Application. But, when we change the query to retrieve another branch, the number showed in Sonarqube Web Application is one, em the number retrieve in the query is another.

For example, I have a component called "contagarantida.garantias-temporarias". The result of RCI showed em Sonarqube Web Application in a branch master is 93,7. I use this query to get the number by Sonar Database, and everything works well:

https://cdn1.imggmi.com/uploads/2019/9/13/ef907e9f7290d61ebcf5313f5879ee05-full.jpg

But, when we change the name of the branch in a query to 1.0.0.21 for example, the number showed em Sonarqube Web Application is 92,6 and the number in Sonarqube Database is 93,70:

https://cdn1.imggmi.com/uploads/2019/9/13/4275372dfad4ec889867c158213a0d66-full.jpg

select    p.kee,
          p.name,
          m.value,
          b.kee,          
          (TO_DATE('19700101','yyyymmdd') + ((s.CREATED_AT/1000)/24/60/60)) CREATED_AT,
          (TO_DATE('19700101','yyyymmdd') + ((s.BUILD_DATE/1000)/24/60/60)) BUILD_DATE
 from sonar_owner_71.snapshots s  
 left join sonar_owner_71.project_measures m on s.uuid = m.analysis_uuid
 left join sonar_owner_71.projects p on m.component_uuid = p.root_uuid
 inner join sonar_owner_71.Project_Branches b on b.project_uuid = p.project_uuid
 where m.metric_id = 161
    and p.scope = 'PRJ'
    and s.islast = 1
    and (TO_DATE('20190101','yyyymmdd')) < (TO_DATE('19700101','yyyymmdd') + ((s.BUILD_DATE/1000)/24/60/60))
    and (p.kee='contagarantida.garantias-temporarias' and b.kee='master');

I can't find the reason for this difference. My query is wrong? Can you help me?

0

There are 0 best solutions below