Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api-service,dashboard): New subscribers page and api #7525

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

desiprisg
Copy link
Contributor

What changed? Why was the change needed?

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

linear bot commented Jan 16, 2025

Copy link

pkg-pr-new bot commented Jan 16, 2025

Open in Stackblitz

@novu/client

npm i https://pkg.pr.new/novuhq/novu/@novu/client@7525

@novu/headless

npm i https://pkg.pr.new/novuhq/novu/@novu/headless@7525

@novu/node

npm i https://pkg.pr.new/novuhq/novu/@novu/node@7525

@novu/notification-center

npm i https://pkg.pr.new/novuhq/novu/@novu/notification-center@7525

novu

npm i https://pkg.pr.new/novuhq/novu@7525

@novu/providers

npm i https://pkg.pr.new/novuhq/novu/@novu/providers@7525

@novu/shared

npm i https://pkg.pr.new/novuhq/novu/@novu/shared@7525

commit: 3106a4b

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit 3106a4b
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/6797c20c190ba600081009be
😎 Deploy Preview https://deploy-preview-7525.dashboard.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 3106a4b
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/6797c20b2e9c940008323f54
😎 Deploy Preview https://deploy-preview-7525.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch from 8eceeae to abd81d2 Compare January 16, 2025 10:22
@desiprisg desiprisg self-assigned this Jan 16, 2025
@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch from abd81d2 to 228b1d3 Compare January 16, 2025 10:30
@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch from 228b1d3 to a6f5e01 Compare January 16, 2025 10:48
@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch from a6f5e01 to 1f79320 Compare January 17, 2025 10:28
Comment on lines 14 to 39
after: command.after || undefined,
before: command.before || undefined,
paginateField: 'id',
limit: command.limit,
sortDirection: command.orderDirection,
sortBy: command.orderBy,
query: {
_environmentId: command.user.environmentId,
_organizationId: command.user.organizationId,
$and: [
{
...(command.email && { email: { $regex: command.email, $options: 'i' } }),
...(command.phone && { phone: { $regex: command.phone, $options: 'i' } }),
...(command.subscriberId && { subscriberId: command.subscriberId }),
...(command.name && {
$expr: {
$regexMatch: {
input: { $concat: ['$firstName', ' ', '$lastName'] },
regex: command.name,
options: 'i',
},
},
}),
},
],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to keep this repo syntax inside the repo, making the exposed methods more reusable, this is super robust in the current implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add a filters option down the road, yes.

Comment on lines +27 to +43
const params = new URLSearchParams({
limit: limit.toString(),
...(after && { after }),
...(before && { before }),
...(orderDirection && { orderDirection }),
...(email && { email }),
...(phone && { phone }),
...(subscriberId && { subscriberId }),
...(name && { name }),
...(orderBy && { orderBy }),
...(orderDirection && { orderDirection }),
});

const { data } = await getV2<{ data: IListSubscribersResponseDto }>(`/subscribers?${params}`, {
environment,
});
return data;
Copy link
Contributor

Choose a reason for hiding this comment

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

shoudn't we attempt to use the SDK here once I deploy it based on your new work

@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch 2 times, most recently from 6aa7f2e to b82058f Compare January 27, 2025 09:34
@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch 2 times, most recently from ebf7c60 to 01ab130 Compare January 27, 2025 13:08
@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch from 01ab130 to 9d7997b Compare January 27, 2025 13:24
Comment on lines +6 to +12
@IsEnum(DirectionEnum)
@IsOptional()
orderDirection: DirectionEnum = DirectionEnum.DESC;

@IsEnum(['updatedAt', 'createdAt'])
@IsOptional()
orderBy: 'updatedAt' | 'createdAt' = 'createdAt';
Copy link
Contributor

Choose a reason for hiding this comment

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

by the way, if those optional params have default we can remove the static default values from
apps/api/src/app/subscribers-v2/subscriber.controller.ts

Suggested change
@IsEnum(DirectionEnum)
@IsOptional()
orderDirection: DirectionEnum = DirectionEnum.DESC;
@IsEnum(['updatedAt', 'createdAt'])
@IsOptional()
orderBy: 'updatedAt' | 'createdAt' = 'createdAt';
@IsEnum(DirectionEnum)
@IsOptional()
orderDirection?: DirectionEnum = DirectionEnum.DESC;
@IsEnum(['updatedAt', 'createdAt'])
@IsOptional()
orderBy?: 'updatedAt' | 'createdAt' = 'createdAt';

Comment on lines +383 to +391
let builder = this.MongooseModel.find(paginationQuery)
.sort({ [sortBy]: sortValue, [paginateField]: sortValue })
.limit(limit + 1);

if (enhanceQuery) {
builder = enhanceQuery(builder);
}

const rawResults = await builder.exec();
Copy link
Contributor

Choose a reason for hiding this comment

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

what is enhanceQuery?

now sure i understand the flow here, won't line 383 will be executed at the time as Promise?

@desiprisg desiprisg force-pushed the nv-5146-subscriber-list-and-filters branch from 7b7a16e to 3106a4b Compare January 27, 2025 17:27
@desiprisg desiprisg merged commit 94ef255 into next Jan 28, 2025
40 checks passed
@desiprisg desiprisg deleted the nv-5146-subscriber-list-and-filters branch January 28, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants