Refactor app fetching and caching logic #21
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant changes to the
core/apps
package to improve the handling and caching of app data from GitHub and subnet sources. The most important changes include the addition of caching mechanisms, modifications to the app data structures, and enhancements to the app retrieval methods.Caching Enhancements:
core/apps/service.go
: Added caching fields (gitHubAppCache
andsubnetAppCache
) to theService
struct and initialized them in theNew
function. Implemented methodsgetGitHubApps
,getGitHubAppByID
, andgetSubnetAppByID
to fetch app data with caching. [1] [2] [3]App Data Structure Modifications:
core/apps/types/types.go
: Updated theApp
struct to include new fields (Description
,Logo
,BannerUrls
,DefaultBannerIndex
,Website
) and changedPeerId
toPeerIds
(a list of strings). Modified related functions to handle these changes. [1] [2] [3] [4]proto/subnet/app/app.pb.go
: Updated the protobuf definition for theApp
struct to reflect the change fromPeerId
toPeerIds
. [1] [2]App Retrieval Enhancements:
core/apps/app_details.go
: Modified theGetApp
method to fetch app data from GitHub and subnet sources, and merge them. Added logic to handle the new fields in theApp
struct.core/apps/app_list.go
: Enhanced theGetApps
method to fetch app data from GitHub and apply filtering criteria. Introduced a newGitHubApp
struct and a helper functionappMatchesFilter
to support these changes.API Adjustments:
internal/api/apps.go
: Updated theappResult
struct and theconvertToAppResult
function to include the new fields from theApp
struct. [1] [2]Miscellaneous:
core/apps/app_report.go
: Adjusted thereportAllRunningContainers
method to handle the updatedPeerIds
field in theApp
struct.