Skip to content

Commit

Permalink
Clean up response
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Dec 22, 2023
1 parent 62d3eba commit 0097882
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const update = async ({
.insertMany(newDataToInsert);
message = `${result.insertedCount} document(s) inserted`;
} else {
message = `No new data to insert for collection - ${collectionName}. The provided data matches the existing records.`;
message = `No new data to insert. The provided data matches the existing records.`;
}

return { message };
Expand Down
10 changes: 7 additions & 3 deletions packages/functions/src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { ApiHandler } from "sst/node/api";
import { Updater } from "@lta-cars-dataset/core/updater";
import { createResponse } from "./utils/createResponse";

export const cars = ApiHandler(async (_evt, context) => {
export const cars = ApiHandler(async (_evt) => {
const COLLECTION_NAME: string = "cars";
const ZIP_FILE_NAME: string = "Monthly New Registration of Cars by Make.zip";
const ZIP_URL: string = `https://datamall.lta.gov.sg/content/dam/datamall/datasets/Facts_Figures/Vehicle Registration/${ZIP_FILE_NAME}`;

const { message } = await Updater.update({
collectionName: "cars",
collectionName: COLLECTION_NAME,
zipFileName: ZIP_FILE_NAME,
zipUrl: ZIP_URL,
});
Expand All @@ -16,17 +17,19 @@ export const cars = ApiHandler(async (_evt, context) => {

return createResponse({
status: 200,
collection: COLLECTION_NAME,
message,
timestamp: new Date().toISOString(),
});
});

export const coe = ApiHandler(async (_evt) => {
const COLLECTION_NAME: string = "coe";
const ZIP_FILE_NAME: string = "COE Bidding Results.zip";
const ZIP_URL: string = `https://datamall.lta.gov.sg/content/dam/datamall/datasets/Facts_Figures/Vehicle Registration/${ZIP_FILE_NAME}`;

const { message } = await Updater.update({
collectionName: "coe",
collectionName: COLLECTION_NAME,
zipFileName: ZIP_FILE_NAME,
zipUrl: ZIP_URL,
});
Expand All @@ -35,6 +38,7 @@ export const coe = ApiHandler(async (_evt) => {

return createResponse({
status: 200,
collection: COLLECTION_NAME,
message,
timestamp: new Date().toISOString(),
});
Expand Down

0 comments on commit 0097882

Please sign in to comment.