Skip to content

Feat/support component versions#73

Merged
woutermont merged 5 commits intodevelopfrom
feat/support-component-versions
May 10, 2021
Merged

Feat/support component versions#73
woutermont merged 5 commits intodevelopfrom
feat/support-component-versions

Conversation

@arnevandoorslaer
Copy link
Copy Markdown

No description provided.

@arnevandoorslaer arnevandoorslaer added the enhancement New feature or request label May 4, 2021
@arnevandoorslaer arnevandoorslaer self-assigned this May 4, 2021
@arnevandoorslaer arnevandoorslaer linked an issue May 4, 2021 that may be closed by this pull request
2 tasks
ofType(shapesDetected),
mergeMap(({shapeIds}) => forkJoin(shapeIds.concat([ 'http://digita.ai/voc/input#input' ]).map((shapeId) => this.semComService.queryComponents(shapeId)))),
map((resultsPerShape) => resultsPerShape.filter((results) => results.length > 0)),
map((resultsPerShape) => resultsPerShape.filter((results) => results.length > 0 && results[0])),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking here, we should rewrite the query function to never return undefined.


async query(filter: Partial<ComponentMetadata>): Promise<ComponentMetadata[]> {
return this.components.filter((component) =>
let filtered = this.components.filter((component) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this to remain a constant, e.g. by returning other constant based on this one.

Comment on lines +25 to +29
if(filtered && filter.version) {
const versions = filtered.map((component) => component.version);
const maxVersion = semver.maxSatisfying(versions, filter.version);
filtered = [ filtered.find((component) => component.version === maxVersion) ];
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrite this so it does not return undefined (e.g. using filter instead of find).

@woutermont woutermont merged commit 4d13663 into develop May 10, 2021
@woutermont woutermont deleted the feat/support-component-versions branch May 10, 2021 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support component versions

2 participants