-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve templates fetching logic and filtering #6068
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
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #6068 will not alter performanceComparing Summary
|
Greptile SummaryOptimized template fetching by directly querying GitHub API for specific release tag ( Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as fetch_app_templates
participant API as GitHub API
participant Assets as Release Assets
Note over Client,API: OLD: Fetch all releases
Client->>API: GET /repos/reflex-dev/templates/releases
API-->>Client: All releases [...]
Client->>Client: Iterate releases to find tag match
Note over Client,Assets: OLD: Linear search for each template
loop For each template
Client->>Assets: Search assets array for template.zip
Assets-->>Client: Return URL or None
end
Note over Client,API: NEW: Direct tag query (optimized)
Client->>API: GET /releases/tags/v{tag}
alt Release exists
API-->>Client: Specific release data
Client->>Client: Build asset_map dictionary (O(1) lookups)
Client->>API: GET templates.json from asset_map
API-->>Client: templates.json content
loop For each template
Client->>Client: Lookup code_url in asset_map (O(1))
end
else Release not found
API-->>Client: 404 Not Found
Client->>Client: Return empty dict
end
|
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.
Additional Comments (1)
-
reflex/utils/templates.py, line 284-287 (link)logic: Cannot assign to
code_urlfield becauseTemplateis a frozen dataclass (line 15). This will raisedataclasses.FrozenInstanceErrorat runtime.
1 file reviewed, 1 comment
Greptile found no issues!From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
This PR optimizes template fetching by retrieving templates directly for a specific tag instead of fetching all releases and filtering afterward.
Additionally, it streamlines the iteration over assets using a prebuilt asset map for faster lookups.