fix naming to introduce applicantDetails

This commit is contained in:
Gaspard Jankowiak 2026-06-05 08:41:06 +02:00
commit b626c8a818

View file

@ -20,10 +20,10 @@ async function getXSRFToken() {
}
async function getApplicant(applicant, token) {
return getApplicantWithProgress(applicant, token)
return getApplicantDetailsWithProgress(applicant, token)
}
async function getApplicantWithProgress(applicant, token, onProgress = () => { }) {
async function getApplicantDetailsWithProgress(applicant, token, onProgress = () => { }) {
return fetch(`https://personal.uni-graz.at/api/erec/job-applications/${applicant.id}`,
{
credentials: "same-origin",
@ -279,12 +279,12 @@ function rip(event) {
progressDialog.initializeApplicant(applicant)
})
const applicantResults = await Promise.allSettled(applicants.map(async (applicant) => {
const applicantDetailsResults = await Promise.allSettled(applicants.map(async (applicant) => {
try {
const applicantData = await getApplicantWithProgress(applicant, token, ({ downloaded, total, bytes }) => {
const applicantDetails = await getApplicantDetailsWithProgress(applicant, token, ({ downloaded, total, bytes }) => {
progressDialog.updateApplicant(applicant, downloaded, total, bytes)
})
return applicantData
return applicantDetails
} catch (error) {
progressDialog.markApplicantFailed(applicant)
throw error
@ -294,23 +294,20 @@ function rip(event) {
progressDialog.setStatus("Creating zip archive...")
const zip = new JSZip()
applicantResults.forEach((result) => {
applicantDetailsResults.forEach((result) => {
if (result.status !== "fulfilled") {
throw result.reason
}
const applicant = result.value
const dirName = `${applicant.last_name}_${applicant.first_name}`
// const dirName = `${sanitizeZipPathSegment(applicant.last_name)}_${sanitizeZipPathSegment(applicant.first_name)}`
const applicantDetails = result.value
// const dirName = `${applicantDetails.last_name}_${applicantDetails.first_name}`
const dirName = `${sanitizeZipPathSegment(applicantDetails.last_name)}_${sanitizeZipPathSegment(applicantDetails.first_name)}`
const applicantDir = zip.folder(dirName)
const files = applicant.application_files ?? []
const files = applicantDetails.application_files ?? []
files.forEach((afile) => {
const ext = afile.file_name.split(".").slice(-1)
const filename = `${afile.field_name}.${ext}`
// const filename = sanitizeZipPathSegment(afile.file_name)
console.log(filename)
console.log(afile.blob)
applicantDir.file(filename, afile.blob)
})
})