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

fix(application-generic): potential get preferences performance improvement #7467

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

LetItRock
Copy link
Contributor

What changed? Why was the change needed?

Get subscriber preferences potential perf improvement.

Screenshots

Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit a438294
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/677f939528858a0008641f91
😎 Deploy Preview https://deploy-preview-7467.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 8, 2025

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

Name Link
🔨 Latest commit a438294
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/677f9395eb5c0c0008302f67
😎 Deploy Preview https://deploy-preview-7467.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.

Comment on lines +130 to +143
const workflowPreferences: ISubscriberPreferenceResponse[] =
this.calculateWorkflowPreferences(
workflowList,
workflowPreferenceSets,
subscriberGlobalPreference,
command.includeInactiveChannels,
);

const nonCriticalWorkflowPreferences = workflowPreferences.filter(
(preference) => !preference.template.critical,
);

return nonCriticalWorkflowPreferences;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all I did in this file is moved the code parts to the class functions to be able to instrument them and see the perf bottleneck

const mergedPreferences = deepMerge(
preferencesList as DeepRequired<PreferencesEntity>[],
);
const mergedPreferences = merge({}, ...preferencesList);
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 assume that the potential issue of slow response times could be that we used the custom deepMerge code that was copied from the lib and had not been maintained for the last 2 years. We want to verify that assumption.

Copy link
Contributor

@SokratisVidros SokratisVidros left a comment

Choose a reason for hiding this comment

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

@LetItRock Nice!

If the hypothesis is verified we should do a follow up PR, and remove the deepMerge utility from the code base as it's used in two more occasions.

@@ -1,9 +1,8 @@
import { merge } from 'lodash';
Copy link
Contributor

Choose a reason for hiding this comment

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

For 100% manual tree shaking

Suggested change
import { merge } from 'lodash';
import merge from 'lodash/merge';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh yeah missed that

@LetItRock LetItRock merged commit 2af9e78 into next Jan 9, 2025
33 checks passed
@LetItRock LetItRock deleted the potential-get-preferences-performance-improvement branch January 9, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants