Skip to content

Commit 2c73168

Browse files
committed
Attempt to fix the update-logs fastest completion issue
1 parent dc8a91f commit 2c73168

File tree

1 file changed

+24
-7
lines changed
  • backend/functions/src/schema/models/submission

1 file changed

+24
-7
lines changed

backend/functions/src/schema/models/submission/service.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type UpdateLogPostSubmission = {
4646
type RelevantErasUpdateLogPost = {
4747
currentSubmission: UpdateLogPostSubmission;
4848
ranksToShow: number | null;
49+
isFastestCompletion: boolean;
4950
relevantChannelIds: Set<string>;
5051
ranking: number | null;
5152
isWR:
@@ -1022,12 +1023,6 @@ export class SubmissionService extends PaginatedService {
10221023
fieldPath
10231024
);
10241025

1025-
const eventStr = generateEventText(
1026-
submission["event.name"],
1027-
submission.participants,
1028-
submission["event.maxParticipants"]
1029-
);
1030-
10311026
const submissionLinks =
10321027
await SubmissionCharacterParticipantLink.getAllSqlRecord({
10331028
select: ["character.name", "character.id"],
@@ -1048,6 +1043,7 @@ export class SubmissionService extends PaginatedService {
10481043
characters: submissionLinks.map((link) => link["character.name"]),
10491044
},
10501045
ranksToShow: null,
1046+
isFastestCompletion: false,
10511047
relevantChannelIds: new Set(),
10521048
ranking: relevantEraRanking,
10531049
isWR: relevantEraRanking === 1 ? { isTie: false } : false,
@@ -1218,7 +1214,7 @@ export class SubmissionService extends PaginatedService {
12181214
// check if this record would appear in any normal style leaderboards. eventEraMode: relevant_eras only
12191215
if (relevantErasUpdateLogPost.ranking) {
12201216
const discordChannelOutputs = await DiscordChannelOutput.getAllSqlRecord({
1221-
select: ["ranksToShow", "discordChannel.channelId"],
1217+
select: ["ranksToShow", "discordChannel.channelId", "participants"],
12221218
where: [
12231219
{
12241220
field: "event.id",
@@ -1256,6 +1252,14 @@ export class SubmissionService extends PaginatedService {
12561252
...discordChannelOutputs.map((ele) => ele.ranksToShow)
12571253
);
12581254

1255+
// if one output and it is for fastest completion, need to adjust the flag
1256+
if (
1257+
discordChannelOutputs.length === 1 &&
1258+
discordChannelOutputs[0].participants === null
1259+
) {
1260+
relevantErasUpdateLogPost.isFastestCompletion = true;
1261+
}
1262+
12591263
relevantErasUpdateLogPost.relevantChannelIds = new Set(
12601264
discordChannelOutputs.map(
12611265
(output) => output["discordChannel.channelId"]
@@ -1341,6 +1345,11 @@ export class SubmissionService extends PaginatedService {
13411345
// generate the discord message for soloPBUpdateLogPost
13421346
// case 1: improvement from X -> Y place
13431347
if (soloPBUpdateLogPost.relevantChannelIds.size) {
1348+
const eventStr = generateEventText(
1349+
submission["event.name"],
1350+
submission.participants,
1351+
submission["event.maxParticipants"]
1352+
);
13441353
if (soloPBUpdateLogPost.currentUserSecondPlaceSubmission) {
13451354
discordMessageContents.push({
13461355
content: `<t:${Math.floor(submission.happenedOn)}:D>\n\n${
@@ -1420,6 +1429,14 @@ export class SubmissionService extends PaginatedService {
14201429
relevantErasUpdateLogPost.relevantChannelIds.size &&
14211430
discordMessageContents.length < 1
14221431
) {
1432+
const eventStr = generateEventText(
1433+
submission["event.name"],
1434+
relevantErasUpdateLogPost.isFastestCompletion
1435+
? null
1436+
: submission.participants,
1437+
submission["event.maxParticipants"]
1438+
);
1439+
14231440
if (
14241441
relevantErasUpdateLogPost.isWR &&
14251442
!relevantErasUpdateLogPost.isWR.isTie &&

0 commit comments

Comments
 (0)