-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into emailSendTask
- Loading branch information
Showing
10 changed files
with
428 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Create a chunked array of new Map() | ||
* @param map map to be chunked | ||
* @param chunkSize The size of the chunk | ||
* @returns Array chunk of new Map() | ||
*/ | ||
|
||
export function mapChunk<T extends Map<any, any>>(map: T, chunkSize: number) { | ||
return Array.from(map.entries()).reduce<T[]>((chunk, curr, index) => { | ||
const ch = Math.floor(index / chunkSize) | ||
if (!chunk[ch]) { | ||
chunk[ch] = new Map() as T | ||
} | ||
chunk[ch].set(curr[0], curr[1]) | ||
return chunk | ||
}, []) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { Expose } from 'class-transformer' | ||
import { IsDateString, IsNumber, IsOptional, IsString } from 'class-validator' | ||
|
||
export class MassMailDto { | ||
@ApiProperty() | ||
@Expose() | ||
@IsString() | ||
listId: string | ||
|
||
@ApiProperty() | ||
@Expose() | ||
@IsString() | ||
templateId: string | ||
|
||
@ApiProperty() | ||
@Expose() | ||
@IsString() | ||
@IsOptional() | ||
subject: string | ||
|
||
//Sendgrid limits sending emails to 1000 at once. | ||
@ApiProperty() | ||
@Expose() | ||
@IsNumber() | ||
@IsOptional() | ||
chunkSize = 1000 | ||
|
||
//Remove users registered after the dateThreshold from mail list | ||
@ApiProperty() | ||
@Expose() | ||
@IsDateString() | ||
@IsOptional() | ||
dateThreshold: Date = new Date() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.