From a650d79bbf0716f32b75292cc88ee520c26ebd81 Mon Sep 17 00:00:00 2001 From: realmayus Date: Fri, 17 Jan 2025 13:19:56 +0100 Subject: [PATCH 1/5] add DATUMHEUTE variable to instant certs --- common/certificate/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/certificate/index.ts b/common/certificate/index.ts index fdcb3a30f..ff274957d 100644 --- a/common/certificate/index.ts +++ b/common/certificate/index.ts @@ -257,6 +257,7 @@ export async function getConfirmationPage(certificateId: string, lang: Language, COURSE_PARTICIPANTS_COUNT: certificate.courseParticipantsCount, COURSE_APPOINTMENTS_COUNT: certificate.courseAppointmentsCount, TOTAL_APPOINTMENTS_DURATION: certificate.totalAppointmentsDuration, + DATUMHEUTE: moment(certificate.createdAt).format('D.M.YYYY'), }); } } @@ -462,6 +463,7 @@ async function createInstantPDFBinary(certificate: InstantCertificate & { studen COURSE_PARTICIPANTS_COUNT: certificate.courseParticipantsCount, COURSE_APPOINTMENTS_COUNT: certificate.courseAppointmentsCount, TOTAL_APPOINTMENTS_DURATION: certificate.totalAppointmentsDuration, + DATUMHEUTE: moment().format('D.M.YYYY'), QR_CODE: await QRCode.toDataURL(link), }); return await generatePDFFromHTML(result, { From ecd0837aff6224d1ff0be88fb12921d94329efa0 Mon Sep 17 00:00:00 2001 From: realmayus Date: Fri, 17 Jan 2025 13:21:18 +0100 Subject: [PATCH 2/5] friendly date --- common/certificate/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/certificate/index.ts b/common/certificate/index.ts index ff274957d..e5c6244fd 100644 --- a/common/certificate/index.ts +++ b/common/certificate/index.ts @@ -251,7 +251,7 @@ export async function getConfirmationPage(certificateId: string, lang: Language, const verificationTemplate = loadTemplate('verifiedInstantCertificatePage', lang); return verificationTemplate({ NAMESTUDENT: certificate.student?.firstname + ' ' + certificate.student?.lastname, - STARTDATE: certificate.startDate, + STARTDATE: moment(certificate.startDate).format('D.M.YYYY'), MATCHES_COUNT: certificate.matchesCount, MATCH_APPOINTMENTS_COUNT: certificate.matchAppointmentsCount, COURSE_PARTICIPANTS_COUNT: certificate.courseParticipantsCount, From 8c045ba984c7ec5a7e0f2809b3cfa2bf98c35584 Mon Sep 17 00:00:00 2001 From: realmayus Date: Fri, 17 Jan 2025 13:22:00 +0100 Subject: [PATCH 3/5] friendly date --- common/certificate/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/certificate/index.ts b/common/certificate/index.ts index e5c6244fd..916c4b1de 100644 --- a/common/certificate/index.ts +++ b/common/certificate/index.ts @@ -457,7 +457,7 @@ async function createInstantPDFBinary(certificate: InstantCertificate & { studen } const result = template({ NAMESTUDENT: name, - STARTDATE: certificate.startDate, + STARTDATE: moment(certificate.startDate).format('D.M.YYYY'), MATCHES_COUNT: certificate.matchesCount, MATCH_APPOINTMENTS_COUNT: certificate.matchAppointmentsCount, COURSE_PARTICIPANTS_COUNT: certificate.courseParticipantsCount, From 6ce99f95a52a36ae25395146a7025d30cca08f9b Mon Sep 17 00:00:00 2001 From: realmayus Date: Fri, 17 Jan 2025 13:30:16 +0100 Subject: [PATCH 4/5] only count lectures that are in the past --- common/certificate/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/certificate/index.ts b/common/certificate/index.ts index 916c4b1de..d1a8d95ea 100644 --- a/common/certificate/index.ts +++ b/common/certificate/index.ts @@ -86,7 +86,7 @@ export async function getCertificatePDF(certificateId: string, requestor: Studen export async function createInstantCertificate(requester: Student, lang: Language): Promise<{ pdf: Buffer; certificate: InstantCertificate }> { const matchesCountPromise = prisma.match.count({ where: { studentId: requester.id } }); - const matchAppointmentsCountPromise = prisma.lecture.count({ where: { match: { studentId: requester.id } } }); + const matchAppointmentsCountPromise = prisma.lecture.count({ where: { match: { studentId: requester.id }, start: { lt: new Date() } } }); const uniqueCourseParticipantsPromise = prisma.subcourse_participants_pupil.groupBy({ by: ['pupilId'], where: { @@ -103,10 +103,12 @@ export async function createInstantCertificate(requester: Student, lang: Languag cancelled: false, subcourse_instructors_student: { some: { studentId: requester.id } }, }, + start: { lt: new Date() }, }, }); const totalAppointmentsDurationPromise = prisma.lecture.aggregate({ where: { + start: { lt: new Date() }, OR: [ { subcourse: { @@ -455,6 +457,7 @@ async function createInstantPDFBinary(certificate: InstantCertificate & { studen if (process.env.ENV == 'dev') { name = `[TEST] ${name}`; } + console.log(`VERIFICATION ${link}`); const result = template({ NAMESTUDENT: name, STARTDATE: moment(certificate.startDate).format('D.M.YYYY'), From c2d4d15da31a44a8114e52e82c1db24e02b94244 Mon Sep 17 00:00:00 2001 From: Marius <38134006+realmayus@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:45:23 +0100 Subject: [PATCH 5/5] Update common/certificate/index.ts Co-authored-by: John Angel <161815068+JeangelLF@users.noreply.github.com> --- common/certificate/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/common/certificate/index.ts b/common/certificate/index.ts index d1a8d95ea..8409e61dc 100644 --- a/common/certificate/index.ts +++ b/common/certificate/index.ts @@ -457,7 +457,6 @@ async function createInstantPDFBinary(certificate: InstantCertificate & { studen if (process.env.ENV == 'dev') { name = `[TEST] ${name}`; } - console.log(`VERIFICATION ${link}`); const result = template({ NAMESTUDENT: name, STARTDATE: moment(certificate.startDate).format('D.M.YYYY'),