Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid doing [0] on a promise instead of on the awaited result #1047

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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)

Check warning on line 32 in meteor/server/api/ExternalMessageQueue.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/api/ExternalMessageQueue.ts#L32

Added line #L32 was not covered by tests
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

Check warning on line 39 in meteor/server/api/ExternalMessageQueue.ts

View check run for this annotation

Codecov / codecov/patch

meteor/server/api/ExternalMessageQueue.ts#L37-L39

Added lines #L37 - L39 were not covered by tests
)}")`,
],
}
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: RundownPlaylist | 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
Loading