From 3191e9f542c1096ea9aaa01545a1bfc073ee1dee Mon Sep 17 00:00:00 2001 From: Angela Cooney Date: Fri, 13 Sep 2024 15:07:05 -0400 Subject: [PATCH] changing scanAll to queryAll and hoping it works --- services/app-api/handlers/measures/get.ts | 2 +- services/app-api/handlers/measures/tests/get.test.ts | 4 ++-- services/database/scripts/transformMeasureTable.ts | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/services/app-api/handlers/measures/get.ts b/services/app-api/handlers/measures/get.ts index 812cfdbae..f192f73e7 100644 --- a/services/app-api/handlers/measures/get.ts +++ b/services/app-api/handlers/measures/get.ts @@ -42,7 +42,7 @@ export const listMeasures = handler(async (event, context) => { ), }; - let queriedMeasures = await dynamoDb.scanAll(params); + let queriedMeasures = await dynamoDb.queryAll(params); for (let v of queriedMeasures) { const measure = measures[parseInt(year as string)]?.filter( (m) => m.measure === (v as Measure)?.measure diff --git a/services/app-api/handlers/measures/tests/get.test.ts b/services/app-api/handlers/measures/tests/get.test.ts index b2d521f58..12ad8df77 100644 --- a/services/app-api/handlers/measures/tests/get.test.ts +++ b/services/app-api/handlers/measures/tests/get.test.ts @@ -12,7 +12,7 @@ import { Errors, StatusCodes } from "../../../utils/constants/constants"; jest.mock("../../../libs/dynamodb-lib", () => ({ get: jest.fn().mockResolvedValue("single measure"), - scanAll: jest + queryAll: jest .fn() .mockResolvedValue([{ measure: "CSQ" }, { measure: "LBW-CH" }]), })); @@ -118,7 +118,7 @@ describe("Test Get Measure Handlers", () => { expect(res.statusCode).toBe(StatusCodes.SUCCESS); expect(res.body).toContain("CSQ"); expect(res.body).toContain("LBW-CH"); - expect(dbLib.scanAll).toHaveBeenCalledWith({ + expect(dbLib.queryAll).toHaveBeenCalledWith({ TableName: "SAMPLE TABLE", testValue: "test", }); diff --git a/services/database/scripts/transformMeasureTable.ts b/services/database/scripts/transformMeasureTable.ts index 58061531c..9ff14c81e 100644 --- a/services/database/scripts/transformMeasureTable.ts +++ b/services/database/scripts/transformMeasureTable.ts @@ -6,9 +6,9 @@ import { } from "@aws-sdk/lib-dynamodb"; const transformMeasureTable = async () => { - const dbClient = buildClient(false); - const tableName = "cmdct-3960-measures"; - const newTableName = "cmdct-3960-cs-measures"; + const dbClient = buildClient(true); + const tableName = "local-measures"; + const newTableName = "local-measure"; console.log(`Processing table ${tableName}`); for await (let entry of scan(dbClient, tableName)) { add(dbClient, newTableName, entry); @@ -33,9 +33,7 @@ async function add(client: DynamoDBDocumentClient, table: string, entry: any) { compoundKey: newCompoundKey, }, }; - console.log("PARAMS!!!!!!!!", params.Item); - console.log("ENTRY!!!!!!!", entry); - // await client.send(new PutCommand(params)); + await client.send(new PutCommand(params)); } function buildClient(isLocal: boolean) {