Skip to content

Commit

Permalink
Rename migration, address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwong89 committed Dec 18, 2024
1 parent 84c6991 commit ff16f98
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/src/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,10 @@ model draft_code {

model email_log {
email_id String @id @db.Uuid
http_status Int?
msg_id String? @db.Uuid
to String?
tx_id String? @db.Uuid
http_status Int?
created_by String? @default("00000000-0000-0000-0000-000000000000")
created_at DateTime? @default(now()) @db.Timestamptz(6)
updated_by String?
Expand Down
14 changes: 7 additions & 7 deletions app/src/services/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Message = {
to: Array<string>;
};

type Email_data = {
type EmailData = {
messages: Array<Message>;
txId: string;
};
Expand Down Expand Up @@ -100,19 +100,19 @@ const service = {
/**
* @function logEmail
* Logs CHES email api calls
* @param {Email_data | null} data Object containing CHES response, or null on error
* @param {EmailData | null} data Object containing CHES response, or null on error
* @param {Array<string>} recipients Array of email strings
* @param {status} status Http status of CHES response
* @returns null
*/
logEmail: async (data: Email_data | null, recipients: Array<string>, status: number) => {
logEmail: async (data: EmailData | null, recipients: Array<string>, status: number) => {
return await prisma.$transaction(async (trx) => {
return await trx.email_log.createMany({
data: recipients.map((x) => ({
data: recipients.map((recipient) => ({
email_id: uuidv4(),
msg_id: data?.messages?.[0].msgId ?? null,
to: x,
tx_id: data?.txId ?? null,
msg_id: data?.messages?.[0].msgId,
to: recipient,
tx_id: data?.txId,
http_status: status
}))
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/types/EmailLog.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IStamps } from '../interfaces/IStamps';

export type EmailLog = {
emailId?: string; // Primary Key
emailId: string; // Primary Key
httpStatus: number;
msgId?: string;
to?: string;
Expand Down
4 changes: 2 additions & 2 deletions app/tests/unit/services/email.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ type Message = {
to: Array<string>;
};

type Email_data = {
type EmailData = {
messages: Array<Message>;
txId: string;
};

const chesResponse: Email_data = {
const chesResponse: EmailData = {
messages: [{ msgId: '9c50c187-4f89-463b-afea-ededc889dd31', to: [] }],
txId: '508a1f8f-b5a1-4d37-a8c9-f7d7c0a86c00'
};
Expand Down

0 comments on commit ff16f98

Please sign in to comment.