Skip to content

Commit

Permalink
Check there is something to store before calling the bulkCreate method
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Feb 25, 2020
1 parent a4d73cd commit 528cb7f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/plugins/usage_collection/server/report/store_report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ export async function storeReport(
],
};
}),
internalRepository.bulkCreate(
appUsage.map(([appId, metric]) => ({
type: 'application_usage_transactional',
attributes: { ...metric, appId, timestamp },
}))
),
appUsage.length
? internalRepository.bulkCreate(
appUsage.map(([appId, metric]) => ({
type: 'application_usage_transactional',
attributes: { ...metric, appId, timestamp },
}))
)
: { saved_objects: [] },
]);
}

0 comments on commit 528cb7f

Please sign in to comment.