device_type details: improve python and SQL perf
device_type details: improve python and SQL perf

Remove:
* redondant calls to timezone.now()
* remove nested queries by caching the list of devices

Change-Id: Ifa632831e141a4e73f9cfc2e16ff9c96294b1ce9

Linaro/lava-server,Linaro/lava-server,Linaro/lava-server,Linaro/lava-server