Skip to content

Commit

Permalink
hotfix remove fireandforget
Browse files Browse the repository at this point in the history
  • Loading branch information
djobbo authored Oct 9, 2023
1 parent 80ac486 commit 5ff9d82
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 84 deletions.
17 changes: 10 additions & 7 deletions packages/server/router/getBHArticles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ export const getBHArticles = publicProcedure //
}),
)
.query(async (req) => {

Check failure on line 18 in packages/server/router/getBHArticles.ts

View workflow job for this annotation

GitHub Actions / Analyze (Lint, pnpm ci:lint)

'req' is defined but never used
const { page, type, max } = req.input
logInfo("getBHArticles", { page, type, max })

Check failure on line 19 in packages/server/router/getBHArticles.ts

View workflow job for this annotation

GitHub Actions / Analyze (Lint, pnpm ci:lint)

Delete `⏎`
const articles = await parseBHArticlesPage(page, type)
return []

if (max) {
return articles.slice(0, parseInt(max.toString()))
}
// const { page, type, max } = req.input
// logInfo("getBHArticles", { page, type, max })

return articles
// const articles = await parseBHArticlesPage(page, type)

// if (max) {
// return articles.slice(0, parseInt(max.toString()))
// }

// return articles
})
4 changes: 3 additions & 1 deletion packages/server/router/getWeeklyRotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ export const getWeeklyRotation = publicProcedure //
.query(async () => {
logInfo("getWeeklyRotation")

return getWeeklyRotationFn()
return []

// return getWeeklyRotationFn()
})
76 changes: 38 additions & 38 deletions packages/server/router/stats/getClanStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,45 @@ export const getClanStats = publicProcedure //

const clan = await withTimeLog(getClan, "BHAPI:clanStats")(clanId)

// Fire and forget
const fireAndForget = Promise.all([
withTimeLog(updateDBClanData, "updateDBClanData")(
{
id: clan.clan_id.toString(),
name: clan.clan_name,
created: clan.clan_create_date,
xp: parseInt(clan.clan_xp),
},
{
abortSignal: controller.signal,
},
).catch((e) => {
logError(
`Failed to update clan#${clan.clan_id} in database`,
e,
)
}),
// withTimeLog(updateDBPlayerAliases, "updateDBPlayerAliases")(
// clan.clan.map((member) => ({
// playerId: member.brawlhalla_id.toString(),
// alias: member.name,
// createdAt: new Date(),
// public: true,
// })),
// {
// abortSignal: controller.signal,
// },
// ).catch((e) => {
// logError(
// `Error updating player aliases for clan#${clan.clan_id}`,
// e,
// )
// }),
])
// // Fire and forget
// const fireAndForget = Promise.all([
// withTimeLog(updateDBClanData, "updateDBClanData")(
// {
// id: clan.clan_id.toString(),
// name: clan.clan_name,
// created: clan.clan_create_date,
// xp: parseInt(clan.clan_xp),
// },
// {
// abortSignal: controller.signal,
// },
// ).catch((e) => {
// logError(
// `Failed to update clan#${clan.clan_id} in database`,
// e,
// )
// }),
// // withTimeLog(updateDBPlayerAliases, "updateDBPlayerAliases")(
// // clan.clan.map((member) => ({
// // playerId: member.brawlhalla_id.toString(),
// // alias: member.name,
// // createdAt: new Date(),
// // public: true,
// // })),
// // {
// // abortSignal: controller.signal,
// // },
// // ).catch((e) => {
// // logError(
// // `Error updating player aliases for clan#${clan.clan_id}`,
// // e,
// // )
// // }),
// ])

waitForRequestTimeout(fireAndForget, {
abortController: controller,
})
// waitForRequestTimeout(fireAndForget, {
// abortController: controller,
// })

return clan
}, "getClanStats"),
Expand Down
24 changes: 12 additions & 12 deletions packages/server/router/stats/getPlayerRanked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ export const getPlayerRanked = publicProcedure //
public: true,
}))

// Fire and forget
const fireAndForget = withTimeLog(
updateDBPlayerAliases,
"updateDBPlayerAliases",
)(aliases, {
abortSignal: controller.signal,
}).catch((e) => {
logError("Error updating player aliases", e)
})
// // Fire and forget
// const fireAndForget = withTimeLog(
// updateDBPlayerAliases,
// "updateDBPlayerAliases",
// )(aliases, {
// abortSignal: controller.signal,
// }).catch((e) => {
// logError("Error updating player aliases", e)
// })

waitForRequestTimeout(fireAndForget, {
abortController: controller,
})
// waitForRequestTimeout(fireAndForget, {
// abortController: controller,
// })

return ranked
}, "getPlayerRanked"),
Expand Down
44 changes: 22 additions & 22 deletions packages/server/router/stats/getPlayerStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,29 @@ export const getPlayerStats = publicProcedure //
})
}

// Fire and forget
const fireAndForget = Promise.all([
withTimeLog(updateDBPlayerAliases, "updateDBPlayerAliases")(
[
{
playerId: stats.brawlhalla_id.toString(),
alias: stats.name,
createdAt: new Date(),
public: true,
},
],
{
abortSignal: controller.signal,
},
).catch((e) => {
logError("Error updating player aliases", e)
}),
updateClanData(),
])
// // Fire and forget
// const fireAndForget = Promise.all([
// withTimeLog(updateDBPlayerAliases, "updateDBPlayerAliases")(
// [
// {
// playerId: stats.brawlhalla_id.toString(),
// alias: stats.name,
// createdAt: new Date(),
// public: true,
// },
// ],
// {
// abortSignal: controller.signal,
// },
// ).catch((e) => {
// logError("Error updating player aliases", e)
// }),
// updateClanData(),
// ])

waitForRequestTimeout(fireAndForget, {
abortController: controller,
})
// waitForRequestTimeout(fireAndForget, {
// abortController: controller,
// })

return stats
}, "getPlayerStats"),
Expand Down
10 changes: 6 additions & 4 deletions packages/server/router/stats/getPowerRankings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export const getPowerRankings = publicProcedure
const { bracket, region } = req.input
logInfo("getPowerRankings", req.input)

return withTimeLog(
parsePowerRankingsPage,
"parsePowerRankingsPage",
)(bracket ?? "1v1", region ?? "us-e")
return []

// return withTimeLog(
// parsePowerRankingsPage,
// "parsePowerRankingsPage",
// )(bracket ?? "1v1", region ?? "us-e")
}, "getPowerRankings"),
)

0 comments on commit 5ff9d82

Please sign in to comment.