Skip to content

Commit

Permalink
Update API return message
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Dec 18, 2023
1 parent 88369c2 commit cf480b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 2 additions & 5 deletions packages/core/src/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export const updater = async () => {
const extractToPath = "/tmp";
const zipFileName = `Monthly New Registration of Cars by Make.zip`;
const zipFilePath = `${extractToPath}/${zipFileName}`;
const csvFileName = `M03-Car_Regn_by_make.csv`;
const csvFilePath = `${extractToPath}/${csvFileName}`;
const zipUrl = `https://datamall.lta.gov.sg/content/dam/datamall/datasets/Facts_Figures/Vehicle Registration/${zipFileName}`;

await downloadFile({
Expand Down Expand Up @@ -57,11 +55,10 @@ export const updater = async () => {
const result = await db.collection("cars").insertMany(newDataToInsert);
message = `${result.insertedCount} document(s) inserted`;
} else {
message = "No new data to insert";
message =
"No new data to insert. The provided data matches the existing records.";
}
}

console.log(message);

return { message };
};
4 changes: 3 additions & 1 deletion packages/functions/src/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { Datasets } from "@lta-datasets-updater/core/datasets";
export const updater = ApiHandler(async (_evt, context) => {
const { message } = await Datasets.updater();

console.log(`Message:`, message);

return {
statusCode: 200,
body: JSON.stringify({ message }),
body: JSON.stringify({ status: 200, message }),
};
});

0 comments on commit cf480b0

Please sign in to comment.