Merge pull request #1239 from balena-io/1238-fix-apps-device-counts

apps: Fix the device count columns being empty
This commit is contained in:
Thodoris Greasidis 2019-05-17 21:14:28 +03:00 committed by GitHub
commit 1bfba85d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,13 +85,24 @@ exports.list =
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
balena.models.application.getAll().then (applications) ->
balena.models.application.getAll
$select: [
'id'
'app_name'
'device_type'
]
$expand: owns__device: $select: 'is_online'
.then (applications) ->
applications.forEach (application) ->
application.device_count = application.owns__device.length
application.online_devices = application.owns__device.filter((d) -> d.is_online == true).length
console.log visuals.table.horizontal applications, [
'id'
'app_name'
'device_type'
'online_devices'
'devices_length'
'device_count'
]
.nodeify(done)