add XLSX summary to the archive

This commit is contained in:
gapato 2026-06-11 15:29:52 +02:00
commit 7e135392a4
3 changed files with 51 additions and 0 deletions

View file

@ -243,6 +243,43 @@ function escapeCsvValue(value) {
return `"${stringValue.replace(/"/g, "\"\"")}"`
}
const API_FIELD_MAP = {
"last_name": "Nachname",
"first_name": "Vorname",
"email": "E-Mail Adresse",
"telephone_number": "Telefonnummer",
"gender": "Geschlecht",
"academic_title_before_name": "Akademischer Grad vorangestellt",
"academic_title_after_name": "Akademischer Grad nachgestellt",
"professional_title": "Berufstitel",
"date_of_birth": "Geburtsdatum",
"highest_educational_degree": "Höchster Bildungsabschluss",
"highest_academic_education": "Höchster akademischer Abschluss",
"final_year_studies": "Letztes Studienjahr (Master oder PhD)",
"first_language": "Erstsprache",
"nationality_arr": "Staatsangehörigkeit",
"relevant_links": "Relevante Links",
"orcid_id": "ORCID ID",
"google_scholar_profile": "Google Scholar Profil",
"how_did_you_become_aware_arr": "Wie sind Sie auf die Stelle aufmerksam geworden?",
}
function createApplicantsXlsx(applicantDetailsList) {
const sorted_mapped = applicantDetailsList.sort((appli1, appli2) => {
appli1.last_name.localeCompare(appli2.last_name)
}).map((appli) => {
const mapped = {}
Object.keys(API_FIELD_MAP).forEach(key => {
mapped[API_FIELD_MAP[key]] = appli[key]
})
return mapped
})
const sheet = XLSX.utils.json_to_sheet(sorted_mapped)
const book = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(book, sheet, "Applications")
return new Uint8Array(XLSX.toXLSXBlob(book).buffer)
}
function createApplicantsCsv(applicantDetailsList) {
const rows = [
CSV_FIELDS.join(",")
@ -523,6 +560,9 @@ function rip(event) {
console.log("Creating applications.csv")
archiveEntries["applications.csv"] = createApplicantsCsv(successfulApplicants)
console.log("Creating applications.xlsx")
archiveEntries["applications.xlsx"] = createApplicantsXlsx(successfulApplicants)
console.log("Creating index.html")
archiveEntries["viewer.html"] = viewerHtmlSource