-
Notifications
You must be signed in to change notification settings - Fork 186
feat: added image transformation #2303
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: added image transformation #2303
Conversation
ConsoleProject ID: Sites (2)
Note Appwrite has a Discord community with over 16 000 members. |
WalkthroughAdds per-project extraction of the Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type 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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/routes/(console)/organization-[organization]/billing/planSummary.svelte
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: e2e
- GitHub Check: build
imageTransformations: projectData?.resources?.find( | ||
(resource) => resource.resourceId === 'imageTransformations' | ||
), |
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.
💡 Verification agent
🧩 Analysis chain
Guard against missing resource to prevent downstream undefined access
.find(...)
can return undefined; later lines dereference .value
/.amount
. Provide a safe fallback here.
- imageTransformations: projectData?.resources?.find(
- (resource) => resource.resourceId === 'imageTransformations'
- ),
+ imageTransformations:
+ projectData?.resources?.find(
+ (resource) => resource.resourceId === 'imageTransformations'
+ ) ?? { value: 0, amount: 0 },
Verification script to confirm consistent identifiers and types:
🏁 Script executed:
#!/bin/bash
# Check occurrences of the new resource across the repo
rg -nP -C3 '\bimageTransformations\b'
# Ensure no singular/typo variants slipped in
rg -nP -C1 '\bimageTransformation\b'
# Spot plan/type definitions that should include `imageTransformations`
rg -nP -C3 '\binterface\b|\btype\b|\bPlan\b' | rg -nP -C3 '\bimageTransformations\b'
Length of output: 16139
Guard missing imageTransformations
lookup to prevent undefined access
Use nullish coalescing to default the .find
result, avoiding any downstream undefined.value
/.amount
errors:
- imageTransformations: projectData?.resources?.find(
- (resource) => resource.resourceId === 'imageTransformations'
- ),
+ imageTransformations:
+ projectData?.resources?.find(
+ (resource) => resource.resourceId === 'imageTransformations'
+ ) ?? { value: 0, amount: 0 },
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
imageTransformations: projectData?.resources?.find( | |
(resource) => resource.resourceId === 'imageTransformations' | |
), | |
imageTransformations: | |
projectData?.resources?.find( | |
(resource) => resource.resourceId === 'imageTransformations' | |
) ?? { value: 0, amount: 0 }, |
🤖 Prompt for AI Agents
In src/routes/(console)/organization-[organization]/billing/planSummary.svelte
around lines 127 to 129, the result of projectData?.resources?.find(...
'imageTransformations') can be undefined and later cause `.value`/`.amount`
access errors; update the assignment to default the find result using nullish
coalescing (e.g., `...find(...) ?? { value: 0, amount: 0 }`) so downstream code
can safely read expected fields, and keep optional chaining where used.
{ | ||
id: `project-${project.projectId}-image-transformations`, | ||
cells: { | ||
item: 'Image transformations', | ||
usage: `${formatNum(project.imageTransformations.value || 0)} / ${currentPlan?.imageTransformations ? formatNum(currentPlan.imageTransformations) : 'Unlimited'}`, | ||
price: formatCurrency(project.imageTransformations.amount || 0) | ||
}, | ||
progressData: createProgressData( | ||
project.imageTransformations.value || 0, | ||
currentPlan?.imageTransformations | ||
), | ||
maxValue: currentPlan?.imageTransformations | ||
}, |
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.
Fix potential runtime error when resource is absent
If a project lacks imageTransformations
, direct property access throws. Use optional chaining/nullish coalescing for usage, price, and progress input.
{
id: `project-${project.projectId}-image-transformations`,
cells: {
item: 'Image transformations',
- usage: `${formatNum(project.imageTransformations.value || 0)} / ${currentPlan?.imageTransformations ? formatNum(currentPlan.imageTransformations) : 'Unlimited'}`,
- price: formatCurrency(project.imageTransformations.amount || 0)
+ usage: `${formatNum(project.imageTransformations?.value ?? 0)} / ${currentPlan?.imageTransformations ? formatNum(currentPlan.imageTransformations) : 'Unlimited'}`,
+ price: formatCurrency(project.imageTransformations?.amount ?? 0)
},
- progressData: createProgressData(
- project.imageTransformations.value || 0,
- currentPlan?.imageTransformations
- ),
+ progressData: createProgressData(
+ project.imageTransformations?.value ?? 0,
+ currentPlan?.imageTransformations
+ ),
maxValue: currentPlan?.imageTransformations
},
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
{ | |
id: `project-${project.projectId}-image-transformations`, | |
cells: { | |
item: 'Image transformations', | |
usage: `${formatNum(project.imageTransformations.value || 0)} / ${currentPlan?.imageTransformations ? formatNum(currentPlan.imageTransformations) : 'Unlimited'}`, | |
price: formatCurrency(project.imageTransformations.amount || 0) | |
}, | |
progressData: createProgressData( | |
project.imageTransformations.value || 0, | |
currentPlan?.imageTransformations | |
), | |
maxValue: currentPlan?.imageTransformations | |
}, | |
{ | |
id: `project-${project.projectId}-image-transformations`, | |
cells: { | |
item: 'Image transformations', | |
usage: `${formatNum(project.imageTransformations?.value ?? 0)} / ${currentPlan?.imageTransformations ? formatNum(currentPlan.imageTransformations) : 'Unlimited'}`, | |
price: formatCurrency(project.imageTransformations?.amount ?? 0) | |
}, | |
progressData: createProgressData( | |
project.imageTransformations?.value ?? 0, | |
currentPlan?.imageTransformations | |
), | |
maxValue: currentPlan?.imageTransformations | |
}, |
🤖 Prompt for AI Agents
In src/routes/(console)/organization-[organization]/billing/planSummary.svelte
around lines 272 to 284, the code assumes project.imageTransformations exists
and may throw if absent; update the usage, price, progressData inputs, and
maxValue to safely handle missing resource by using optional chaining and
nullish coalescing (e.g., project.imageTransformations?.value ?? 0 and
project.imageTransformations?.amount ?? 0) and pass
currentPlan?.imageTransformations similarly for progress and maxValue so no
direct property access occurs on undefined.
What does this PR do?
added image transformations to usage
Test Plan
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit
New Features
Chores