Skip to content

Commit

Permalink
refactor: remove xls file generation (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevbarns authored Dec 14, 2023
1 parent a965c3b commit 5922ba2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 324 deletions.
32 changes: 0 additions & 32 deletions server/src/common/utils/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
import path from "path"

import csvToJson from "convert-csv-to-json"
import { Options as CsvParseOptions, parse } from "csv-parse"
import { isEmpty, pickBy } from "lodash-es"
import XLSX from "xlsx"

import config from "../../config"
import __dirname from "../dirname"

import { FTPClient } from "./ftpUtils"

export const readJsonFromCsvFile = (localPath) => {
return csvToJson.getJsonFromCsv(localPath)
}

export const readXLSXFile = (localPath) => {
const workbook = XLSX.readFile(localPath, { codepage: 65001 })
return { sheet_name_list: workbook.SheetNames, workbook }
}

export const createXLSXFile = (data, localPath) => {
const workbook = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(workbook, XLSX.utils.json_to_sheet(data), "data")

// @ts-expect-error writeFileAsync Cb function is not properly typed
XLSX.writeFileAsync(path.join(localPath), workbook, (e) => {
if (e) {
console.log(e)
throw new Error("La génération du fichier excel à échoué : ", e)
}
})
}

export const convertIntoBuffer = (workbook) => {
return XLSX.write(workbook, { type: "buffer", bookType: "xlsx" })
}

export const removeLine = (data, regex) => {
return data
.split("\n")
.filter((val) => !regex.test(val))
.join("\n")
}

export const prepareMessageForMail = (data) => {
const result = data ? data.replace(/(<([^>]+)>)/gi, "") : data
return result ? result.replace(/\r\n|\r|\n/gi, "<br />") : result
Expand Down
151 changes: 0 additions & 151 deletions server/src/jobs/campaign/generateCsvForCampaign.ts

This file was deleted.

141 changes: 0 additions & 141 deletions server/src/jobs/campaign/generateLbacLinksForParcoursup.ts

This file was deleted.

0 comments on commit 5922ba2

Please sign in to comment.