bbc / hive-mind

Device management service for the Hive
MIT License
9 stars 3 forks source link

Incorrect information in database #181

Open Asimk21 opened 7 years ago

Asimk21 commented 7 years ago

Navigate to https://hivemind.cloud.bbc.co.uk/api/devices/ API calls results in 500 internal server error.

Somehow hivemind database tables get incorrect information where device_type='Tv' and plugin_type='HiveMindHive::Plugin'.

For 'HiveMindHive::Plugin' and 'device_type=Tv', this was causing issue.

d = Device.includes(:ips, :macs, :brand, :plugin, :model => [:device_type] ).all.group_by { |d| d.model && d.model.device_type }.keys.first
@devices = = Device.includes(:ips, :macs, :brand, :plugin, :model => [:device_type] ).all.group_by { |d| d.model && d.model.device_type }
@devices[d].each do |dev| 
    if dev.plugin_type == 'HiveMindHive::Plugin'  
       puts [dev.device_type, dev.plugin_type, dev.inspect] 
    end 
end
jrmhaig commented 7 years ago

I think this may happen if a device reregisters as a different type. This needs to be checked at registration to avoid a conflict.