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

Bugfix- Fetch parent feature using topLevel flag #478

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shashankbrgowda
Copy link
Contributor

@shashankbrgowda shashankbrgowda commented Nov 14, 2024

The current behavior is returning the top-level feature (gene) for all requests, but the desired behavior is to return the immediate parent of the featureId.

@garrettjstevens
Copy link
Contributor

Can we simplify this more by not even calling getFeatureFromId if topLevel is true? i.e. does this change also fix the bug you were seeing?

diff --git a/packages/apollo-collaboration-server/src/features/features.service.ts b/packages/apollo-collaboration-server/src/features/features.service.ts
--- a/packages/apollo-collaboration-server/src/features/features.service.ts
+++ b/packages/apollo-collaboration-server/src/features/features.service.ts
@@ -86,12 +86,14 @@ export class FeaturesService {
       this.logger.error(errMsg)
       throw new NotFoundException(errMsg)
     }
+    if (topLevel) {
+      return topLevelFeature
+    }
 
     // Now we need to find correct top level feature or sub-feature inside the feature
     const foundFeature = this.getFeatureFromId(
       topLevelFeature,
       featureId,
-      topLevel,
     )
     if (!foundFeature) {
       const errMsg = 'ERROR when searching feature by featureId'
@@ -111,8 +113,6 @@ export class FeaturesService {
   getFeatureFromId(
     feature: Feature,
     featureId: string,
-    topLevel?: boolean,
-    parent?: Feature | null,
   ): Feature | null {
     this.logger.verbose(`Entry=${JSON.stringify(feature)}`)
 
@@ -120,9 +120,6 @@ export class FeaturesService {
       this.logger.debug(
         `Top level featureId matches in object ${JSON.stringify(feature)}`,
       )
-      if (topLevel && parent) {
-        return parent
-      }
       return feature
     }
     // Check if there is also childFeatures in parent feature and it's not empty
@@ -134,13 +131,8 @@ export class FeaturesService {
       const subFeature = this.getFeatureFromId(
         childFeature,
         featureId,
-        topLevel,
-        feature,
       )
       if (subFeature) {
-        if (topLevel) {
-          return feature
-        }
         return subFeature
       }
     }

@shashankbrgowda
Copy link
Contributor Author

shashankbrgowda commented Nov 15, 2024

Can we simplify this more by not even calling getFeatureFromId if topLevel is true? i.e. does this change also fix the bug you were seeing?

diff --git a/packages/apollo-collaboration-server/src/features/features.service.ts b/packages/apollo-collaboration-server/src/features/features.service.ts
--- a/packages/apollo-collaboration-server/src/features/features.service.ts
+++ b/packages/apollo-collaboration-server/src/features/features.service.ts
@@ -86,12 +86,14 @@ export class FeaturesService {
       this.logger.error(errMsg)
       throw new NotFoundException(errMsg)
     }
+    if (topLevel) {
+      return topLevelFeature
+    }
 
     // Now we need to find correct top level feature or sub-feature inside the feature
     const foundFeature = this.getFeatureFromId(
       topLevelFeature,
       featureId,
-      topLevel,
     )
     if (!foundFeature) {
       const errMsg = 'ERROR when searching feature by featureId'
@@ -111,8 +113,6 @@ export class FeaturesService {
   getFeatureFromId(
     feature: Feature,
     featureId: string,
-    topLevel?: boolean,
-    parent?: Feature | null,
   ): Feature | null {
     this.logger.verbose(`Entry=${JSON.stringify(feature)}`)
 
@@ -120,9 +120,6 @@ export class FeaturesService {
       this.logger.debug(
         `Top level featureId matches in object ${JSON.stringify(feature)}`,
       )
-      if (topLevel && parent) {
-        return parent
-      }
       return feature
     }
     // Check if there is also childFeatures in parent feature and it's not empty
@@ -134,13 +131,8 @@ export class FeaturesService {
       const subFeature = this.getFeatureFromId(
         childFeature,
         featureId,
-        topLevel,
-        feature,
       )
       if (subFeature) {
-        if (topLevel) {
-          return feature
-        }
         return subFeature
       }
     }

This will return topLevelFeature (gene) for all requests. We need to return immediate parent of requested featureId.

Sorry for the confusion with description, I've updated it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants