add some protection for missing data when doing the reports

it happens that if we remove a user, the data regarding the ruby
applications and the security alerts remains, thus we should check if
certain ruby application has a user associated. I have also add some
checks to make sure objects are not nil.