Skip to content

Commit

Permalink
format table
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceKatt committed May 3, 2021
1 parent c689ea9 commit a310010
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/output/tableOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,33 @@ export class TableOutput implements Output {
SodaResponseHeaders.applicant,
SodaResponseHeaders.address,
SodaResponseHeaders.fooditems,
SodaResponseHeaders.dayshours,
SodaResponseHeaders.status,
SodaResponseHeaders.longitude,
SodaResponseHeaders.latitude,
SodaResponseHeaders.schedule,
];
const truncateLength = 30;
const truncateLength = 25;
return data.reduce((result, element) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const newElement: any = {};
let success = true;

const elementKeys = Object.keys(element);
for (const header of relevantHeaders) {
if (elementKeys.indexOf(header) < 0) {
success = false;
break;
if (elementKeys.indexOf(header) > -1) {
if (header === SodaResponseHeaders.schedule) {
newElement[header] = String(element[header]);
} else {
newElement[header] = String(element[header]).substring(
0,
truncateLength,
);
}
} else {
newElement[header] = 'NULL';
}
newElement[header] = String(element[header]).substring(
0,
truncateLength,
);
}

if (success) {
result.push(newElement);
}
result.push(newElement);

return result;
}, []);
Expand Down

0 comments on commit a310010

Please sign in to comment.