Imediava's Blog

Just another WordPress.com site

Sonar: Hide snapshot from the TimeMachine

If you use Sonar (http://www.sonarsource.org) as your code quality control tool maybe at some point you’ve wondered how you can delete a snapshots which no longer provide useful data.

You can run into this problem if you run a sonar measurement over a failed build or if you change the quality profile of your server for testing purposes and you wanna get rid of that confusing data later.

The problem is that those snapshots are not useful for you anymore yet there’s no way to hide them. This affects specially the TimeMachine section where the graph is altered by those useless snapshots.

As far as I know Sonar doesn’t provide a way to do this through it’s interface. The only alternative I’ve found it’s extracted from the following Jira issue:

http://jira.codehaus.org/browse/SONAR-893

To make use of this tip you need to have access to the database that stores Sonar data. Once you’re logged into the database server you can identify the ids of the snapshots you wanna hide with the following SQL query that list all the snapshots of a project:

select s.id as snapshot_id, p.name, p.kee,  s.created_at 
         from projects p, snapshots s 
         where s.project_id = p.id and p.scope = 'PRJ' and p.qualifier='TRK' and name like "%MyProjectName%" 
         order by s.created_at desc

Now that we have the id of the snapshot we wanna hide we can make it invisible with the following update statement:

update snapshots 
         set status='U' 
         where root_snapshot_id='${snapshot_id}' or id ='${snapshot_id}'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: