preload: Replace my_application query with the SDKs application.getAll()

Change-type: patch
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
This commit is contained in:
Thodoris Greasidis 2021-09-07 02:09:39 +03:00
parent dc59b7e4b0
commit d793335287

View File

@ -331,7 +331,6 @@ Can be repeated to add multiple certificates.\
readonly applicationExpandOptions: PineExpand<Application> = {
owns__release: {
$select: ['id', 'commit', 'end_timestamp', 'composition'],
$orderby: [{ end_timestamp: 'desc' }, { id: 'desc' }],
$expand: {
contains__image: {
$select: ['image'],
@ -345,6 +344,7 @@ Can be repeated to add multiple certificates.\
$filter: {
status: 'success',
},
$orderby: [{ end_timestamp: 'desc' }, { id: 'desc' }],
},
should_be_running__release: {
$select: 'commit',
@ -378,17 +378,9 @@ Can be repeated to add multiple certificates.\
const balena = getBalenaSdk();
const deviceTypes = await this.getDeviceTypesWithSameArch(deviceTypeSlug);
// TODO: remove the explicit types once https://github.com/balena-io/balena-sdk/pull/889 gets merged
return balena.pine.get<
Application,
Array<
ApplicationWithDeviceType & {
should_be_running__release: [Release?];
}
>
>({
resource: 'my_application',
options: {
return (await balena.models.application.getAll({
$select: ['id', 'app_name', 'should_track_latest_release'],
$expand: this.applicationExpandOptions,
$filter: {
is_for__device_type: {
$any: {
@ -411,11 +403,12 @@ Can be repeated to add multiple certificates.\
},
},
},
$expand: this.applicationExpandOptions,
$select: ['id', 'app_name', 'should_track_latest_release'],
$orderby: 'app_name asc',
},
});
})) as Array<
ApplicationWithDeviceType & {
should_be_running__release: [Release?];
}
>;
}
async selectApplication(deviceTypeSlug: string) {