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

cleanup PreloadingNetworkStoreClient assumes its delegate is CachedNetworkStoreClient #420

Open
jonenst opened this issue Jul 30, 2024 · 1 comment · May be fixed by #464
Open

cleanup PreloadingNetworkStoreClient assumes its delegate is CachedNetworkStoreClient #420

jonenst opened this issue Jul 30, 2024 · 1 comment · May be fixed by #464

Comments

@jonenst
Copy link
Collaborator

jonenst commented Jul 30, 2024

Describe the current behavior

public List<Resource<SubstationAttributes>> getSubstations(UUID networkUuid, int variantNum) {
    ensureCached(ResourceType.SUBSTATION, networkUuid, variantNum);
    return delegate.getSubstations(networkUuid, variantNum);
}

private void ensureCached(ResourceType resourceType, UUID networkUuid, int variantNum) {
    loadToCache(resourceType, networkUuid, variantNum);
    resourceTypes.add(resourceType);
} 

private void loadToCache(ResourceType resourceType, UUID networkUuid, int variantNum) {
    delegate.getSubstations(networkUuid, variantNum);
}

wee call getSubstations twice, so it works only for CachedNetworkStoreClient

Describe the expected behavior

refactor the code to force the delegate to be of type cachednetworkstoreclient for preloadingnetworkstoreclient ? because it doesn't make sense to preload for a client that doesn't not cache.

Describe the motivation

reduce code complexity

Extra Information

No response

@jonenst
Copy link
Collaborator Author

jonenst commented Jul 30, 2024

when we are not preloading, we should call the delegate only once (e.g. getSubstations() and not ALL_COLLECTION_FOR_BUS_VIEW or getSwitches)
when we are preloading (first time calling (checked with cachedResourcesTypes) either getSubstation() or getSubstations and ALL_COLLECTION_FOR_BUS_VIEW), call the method with more data, and then call the right method.

antoinebhs added a commit that referenced this issue Oct 16, 2024
Signed-off-by: BOUHOURS Antoine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant