Skip to content

Commit

Permalink
fix: json volume was missing keys
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Apr 19, 2024
1 parent f099912 commit 9eb1999
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,8 @@ export function generateVolumes(reportType: ReportType) {
});
}

function formatDataset(data: BlipTimelineEntry[]) {
return data.map((blip) => [
blip.name,
blip.ring,
blip.quadrant,
blip.isNew.toString().toUpperCase(),
getStatus(blip),
escapeDescriptionHTML(blip.descriptionHtml),
]);
}

function generateCSV(volume: string, volumeData: BlipTimelineEntry[]) {
const data = formatDataset(volumeData);
const data = formatCSVDataset(volumeData);

const csvData = data.map((row) => row.join(','));
csvData.unshift(CSV_HEADERS.join(','));
Expand All @@ -72,7 +61,14 @@ function generateCSV(volume: string, volumeData: BlipTimelineEntry[]) {
}

function generateJSON(volume: string, volumeData: BlipTimelineEntry[]) {
const data = formatDataset(volumeData);
const data = volumeData.map((row) => ({
name: row.name,
ring: row.ring,
quadrant: row.quadrant,
isNew: row.isNew.toString().toUpperCase(),
status: getStatus(row),
description: escapeDescriptionHTML(row.descriptionHtml),
}));

const filename = `${FILES.VOLUMES.FOLDER}/json/${getVolumeFileName(
volume,
Expand All @@ -85,7 +81,7 @@ async function updateGoogleSheets(
volume: string,
volumeData: BlipTimelineEntry[],
) {
const data = formatDataset(volumeData);
const data = formatCSVDataset(volumeData);
data.unshift(CSV_HEADERS);

const sheetName = `Vol ${volume} (${getVolumePublicationDate(volume)})`;
Expand Down Expand Up @@ -157,3 +153,14 @@ async function updateGoogleSheets(
`Google Sheet ${sheetName} has been updated: ${URLS.GOOGLE_SHEET}${sheetId}&sheetName=${sheetName}`,
);
}

function formatCSVDataset(data: BlipTimelineEntry[]) {
return data.map((blip) => [
blip.name,
blip.ring,
blip.quadrant,
blip.isNew.toString().toUpperCase(),
getStatus(blip),
escapeDescriptionHTML(blip.descriptionHtml),
]);
}

0 comments on commit 9eb1999

Please sign in to comment.