-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Initial commit #22005
base: main
Are you sure you want to change the base?
Initial commit #22005
Conversation
Deployed to staging with ID: |
WalkthroughThe changes involve a significant refactoring of member data querying in the Ghost CMS export service. The previous single-query approach has been replaced with a concurrent querying strategy using Changes
Sequence DiagramsequenceDiagram
participant Exporter as Member Exporter
participant DB as Database
Exporter->>+DB: Fetch Members Query
Exporter->>+DB: Fetch Tiers Query
Exporter->>+DB: Fetch Labels Query
Exporter->>+DB: Fetch Subscriptions Query
Exporter->>+DB: Fetch Stripe Customers Query
DB-->>-Exporter: Members Results
DB-->>-Exporter: Tiers Results
DB-->>-Exporter: Labels Results
DB-->>-Exporter: Subscriptions Results
DB-->>-Exporter: Stripe Customers Results
Exporter->>Exporter: Construct Maps
Exporter->>Exporter: Enrich Member Data
Poem
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
ghost/core/core/server/services/members/exporter/query.js (1)
84-100
: Optimize performance by using lookup maps for products and labelsUsing
.find()
within a loop can lead to performance issues, especially with large datasets. Consider creating a lookup map forallProducts
andallLabels
to improve the efficiency of your code.Example Implementation:
Create lookup maps outside the loop:
const productMap = new Map(allProducts.map(product => [product.id, product])); const labelMap = new Map(allLabels.map(label => [label.id, label]));Refactor the tier and label mapping:
const tierDetails = tierIds.map((id) => { const tier = productMap.get(id); if (tier) { return { name: tier.get('name') }; } }).filter(Boolean); const labelDetails = labelIds.map((id) => { const label = labelMap.get(id); if (label) { return { name: label.get('name') }; } }).filter(Boolean);
Deployed to staging with ID: |
Summary by CodeRabbit