Skip to content

Commit

Permalink
Fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Lloyd committed Nov 25, 2024
1 parent 3a17c34 commit ad0e683
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
70 changes: 40 additions & 30 deletions packages/account_space_updater/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ describe("handler", () => {
);
};

const getInitialAccountSpace = async () => {
const initialAccountSpaceResult = await db.query<{
spaceLeft: string;
spaceTotal: string;
fileLeft: string;
fileTotal: string;
}>(
interface AccountSpaceStartingState {
spaceLeft: string;
spaceTotal: string;
fileLeft: string;
fileTotal: string;
}

const getInitialAccountSpace = async (): Promise<
AccountSpaceStartingState | undefined
> => {
const initialAccountSpaceResult = await db.query<AccountSpaceStartingState>(
`SELECT
spaceLeft AS "spaceLeft",
spaceTotal AS "spaceTotal",
Expand All @@ -48,11 +52,15 @@ describe("handler", () => {
return initialAccountSpaceResult.rows[0];
};

const getUpdatedAccountSpace = async () => {
const updatedAccountSpaceResult = await db.query<{
spaceLeft: string;
fileLeft: string;
}>(
interface AccountSpaceAfterUpdate {
spaceLeft: string;
fileLeft: string;
}

const getUpdatedAccountSpace = async (): Promise<
AccountSpaceAfterUpdate | undefined
> => {
const updatedAccountSpaceResult = await db.query<AccountSpaceAfterUpdate>(
`SELECT
spaceLeft AS "spaceLeft",
fileLeft AS "fileLeft"
Expand All @@ -64,24 +72,26 @@ describe("handler", () => {
return updatedAccountSpaceResult.rows[0];
};

const getLedgerEntry = async () => {
const ledgerEntryResult = await db.query<{
type: string;
spaceDelta: string;
fileDelta: string;
fromSpaceBefore: string;
fromSpaceLeft: string;
fromSpaceTotal: string;
fromFileBefore: string;
fromFileLeft: string;
fromFileTotal: string;
toSpaceBefore: string;
toSpaceLeft: string;
toSpaceTotal: string;
toFileBefore: string;
toFileLeft: string;
toFileTotal: string;
}>(
interface LedgerEntry {
type: string;
spaceDelta: string;
fileDelta: string;
fromSpaceBefore: string;
fromSpaceLeft: string;
fromSpaceTotal: string;
fromFileBefore: string;
fromFileLeft: string;
fromFileTotal: string;
toSpaceBefore: string;
toSpaceLeft: string;
toSpaceTotal: string;
toFileBefore: string;
toFileLeft: string;
toFileTotal: string;
}

const getLedgerEntry = async (): Promise<LedgerEntry | undefined> => {
const ledgerEntryResult = await db.query<LedgerEntry>(
`SELECT
type,
spaceDelta "spaceDelta",
Expand Down
23 changes: 10 additions & 13 deletions packages/account_space_updater/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,17 @@ export const extractFileAttributesFromS3Message = (
recordId: parsedBody.body.record.recordId,
operation: Operation.Upload,
};
} else {
if (parsedBody.body.newRecord === undefined) {
logger.error(
`record.copy event missing newRecord: ${JSON.stringify(
parsedBody.body
)}`
);
throw new Error("newRecord field missing in body of record.copy");
}
return {
recordId: parsedBody.body.newRecord.recordId,
operation: Operation.Copy,
};
}
if (parsedBody.body.newRecord === undefined) {
logger.error(
`record.copy event missing newRecord: ${JSON.stringify(parsedBody.body)}`
);
throw new Error("newRecord field missing in body of record.copy");
}
return {
recordId: parsedBody.body.newRecord.recordId,
operation: Operation.Copy,
};
};

export const handler: SQSHandler = async (event: SQSEvent, _, __) => {
Expand Down

0 comments on commit ad0e683

Please sign in to comment.