Skip to content

Commit

Permalink
changing scanAll to queryAll and hoping it works
Browse files Browse the repository at this point in the history
  • Loading branch information
angelaco11 committed Sep 13, 2024
1 parent 2d836d6 commit 3191e9f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion services/app-api/handlers/measures/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const listMeasures = handler(async (event, context) => {
),
};

let queriedMeasures = await dynamoDb.scanAll<Measure>(params);
let queriedMeasures = await dynamoDb.queryAll<Measure>(params);
for (let v of queriedMeasures) {
const measure = measures[parseInt(year as string)]?.filter(
(m) => m.measure === (v as Measure)?.measure
Expand Down
4 changes: 2 additions & 2 deletions services/app-api/handlers/measures/tests/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]),
}));
Expand Down Expand Up @@ -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",
});
Expand Down
10 changes: 4 additions & 6 deletions services/database/scripts/transformMeasureTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 3191e9f

Please sign in to comment.