Skip to content

Commit

Permalink
fix: doing [0] on a promise, rather than on the awaited result
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian authored Oct 6, 2023
1 parent ef4a86f commit 0c7104e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions meteor/server/api/ExternalMessageQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ function updateExternalMessageQueueStatus(): void {
statusCode: StatusCode.GOOD,
}
if (messagesOnQueueCount > 0) {
// TODO - this is fetching ALL of the docs that match the query, then only using the first
const messagesOnQueueExample = await ExternalMessageQueue.findOneAsync(query)[0]
const messagesOnQueueExample = await ExternalMessageQueue.findOneAsync(query)
status = {
statusCode: StatusCode.WARNING_MAJOR,
messages: [
`There are ${messagesOnQueueCount} unsent messages on queue (one of the unsent messages has the error message: "${
messagesOnQueueExample.errorMessage
}", to receiver "${messagesOnQueueExample.type}", "${JSON.stringify(
messagesOnQueueExample.receiver
messagesOnQueueExample?.errorMessage
}", to receiver "${messagesOnQueueExample?.type}", "${JSON.stringify(
messagesOnQueueExample?.receiver
)}")`,
],
}
Expand Down
4 changes: 3 additions & 1 deletion meteor/server/api/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ async function isAllowedToRunCleanup(): Promise<string | void> {

const studios = await Studios.findFetchAsync({}, { fields: { _id: 1 } })
for (const studio of studios) {
const activePlaylist: RundownPlaylist | undefined = await getActiveRundownPlaylistsInStudioFromDb(studio._id)[0]
const activePlaylist: DBRundownPlaylist | undefined = (
await getActiveRundownPlaylistsInStudioFromDb(studio._id)
)[0]
if (activePlaylist) {
return `There is an active RundownPlaylist: "${activePlaylist.name}" in studio "${studio.name}" (${activePlaylist._id}, ${studio._id})`
}
Expand Down

0 comments on commit 0c7104e

Please sign in to comment.