Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions constants/tables.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const EVENTS_TABLE = "biztechEvents";
export const MEMBERSHIPS2021_TABLE = "biztechMemberships2021";
export const MEMBERS2022_TABLE = "biztechMembers2022";
export const MEMBERS2023_TABLE = "biztechMembers2023"
export const MEMBERS2024_TABLE = "biztechMembers2024";
export const PRIZES_TABLE = "biztechPrizes";
export const STICKERS_TABLE = "biztechStickers";
Expand Down
32 changes: 30 additions & 2 deletions services/members/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import docClient from "../../lib/docClient";
const {
MEMBERS2024_TABLE
} = require("../../constants/tables");
const {
MEMBERS2023_TABLE
} = require("../../constants/tables");
const {
MEMBERS2022_TABLE
} = require("../../constants/tables");
const {
MEMBERSHIPS2021_TABLE
} = require("../../constants/tables");

export const create = async (event, ctx, callback) => {
const timestamp = new Date().getTime();
Expand Down Expand Up @@ -39,7 +48,7 @@ export const create = async (event, ctx, callback) => {
updatedAt: timestamp
},
TableName:
MEMBERS2024_TABLE +
MEMBERS2024_TABLE +
(process.env.ENVIRONMENT ? process.env.ENVIRONMENT : ""),
ConditionExpression: "attribute_not_exists(id)"
};
Expand Down Expand Up @@ -95,7 +104,26 @@ export const get = async (event, ctx, callback) => {
export const getAll = async (event, ctx, callback) => {
try {
// scan the table
const members = await db.scan(MEMBERS2024_TABLE);
const year = event.queryStringParameters.year;

// Get the table name based on the year from query param
let tableName;
switch (year) {
case "2021":
tableName = MEMBERSHIPS2021_TABLE;
Copy link
Member

@ddennis924 ddennis924 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rlly good work, make sure to include the environment in the table query, so when we are in PROD it shows the prod tables, look at line 51 for an example TableName: MEMBERS2024_TABLE + (process.env.ENVIRONMENT ? process.env.ENVIRONMENT : ""),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break;
case "2022":
tableName = MEMBERS2022_TABLE;
break;
case "2023":
tableName = MEMBERS2023_TABLE;
break;
case "2024":
tableName = MEMBERS2024_TABLE;
break;
}
const members = await db.scan(tableName);
// const members = await db.scan(MEMBERS2024_TABLE);

// re-organize the response
let response = {
Expand Down