Skip to content
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
2 changes: 1 addition & 1 deletion convex/_model/lists/_helpers/checkListSubmittedOnTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const checkListSubmittedOnTime = async (
if (doc.tournamentRegistrationId) {
const tournamentRegistration = await getDocStrict(ctx, doc.tournamentRegistrationId);
const tournament = await getDocStrict(ctx, tournamentRegistration.tournamentId);
if (doc._creationTime <= tournament.listSubmissionClosesAt) {
if ((doc.submittedAt ?? doc._creationTime) <= tournament.listSubmissionClosesAt) {
return true;
}
return false;
Expand Down
7 changes: 3 additions & 4 deletions convex/_model/lists/mutations/createList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ export const createList = async (
): Promise<Id<'lists'>> => {
const userId = await checkAuth(ctx);

let computedFields = {
const computedFields = {
locked: false,
submittedAt: Date.now(),
};

if (args.tournamentRegistrationId) {
const tournamentRegistration = await getDocStrict(ctx, args.tournamentRegistrationId);
const tournament = await getDocStrict(ctx, tournamentRegistration.tournamentId);
computedFields = {
locked: Date.now() > tournament.listSubmissionClosesAt,
};
computedFields.locked = computedFields.submittedAt > tournament.listSubmissionClosesAt;
}

return await ctx.db.insert('lists', {
Expand Down
1 change: 1 addition & 0 deletions convex/_model/lists/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const editableFields = {
* Fields which can only be edited using special mutations, or which are set programmatically.
*/
export const computedFields = {
submittedAt: v.optional(v.number()),
modifiedAt: v.optional(v.number()),
locked: v.boolean(),
};
Expand Down
10 changes: 10 additions & 0 deletions convex/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ export const moveSoloCompetitorScoreAdjustments = migrations.define({
},
});

export const backfillListSubmittedAt = migrations.define({
table: 'lists',
migrateOne: async (ctx, doc) => {
if (doc.submittedAt !== undefined) {
return;
}
await ctx.db.patch(doc._id, { submittedAt: doc._creationTime });
},
});

export const convertPlayedAt = migrations.define({
table: 'matchResults',
migrateOne: async (ctx, doc) => {
Expand Down
Loading