BUG: division by zero when enabled GW discovery but not GW has been discovered


I got this when enabled gw discovery, but no one gw has been discovered:

appserver_1      | time="2018-04-04T01:06:09Z" level=error msg="send gateway ping error: get gateway for ping error: select error: pq: division by zero"
postgresql_as_1  | ERROR:  division by zero
postgresql_as_1  | STATEMENT:  
postgresql_as_1  | 			select
postgresql_as_1  | 				g.*
postgresql_as_1  | 			from gateway g
postgresql_as_1  | 			inner join network_server ns
postgresql_as_1  | 				on ns.id = g.network_server_id
postgresql_as_1  | 			where
postgresql_as_1  | 				ns.gateway_discovery_enabled = true
postgresql_as_1  | 				and g.ping = true
postgresql_as_1  | 				and (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval '24 hours' / ns.gateway_discovery_interval)))
postgresql_as_1  | 			order by last_ping_sent_at
postgresql_as_1  | 			limit 1
postgresql_as_1  | 			for update

Yes, I’m aware of it and it will be fixed by the next release. Please use GitHub for reporting bugs :slight_smile: https://github.com/brocaar/lora-app-server/issues/226