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

Fix #272: cherry pick api and helpers implemented #273

Merged
merged 4 commits into from
Jun 16, 2023

Conversation

antoineatstariongroup
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the COMET-SDK code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

Fix #272

  • CherryPick API EndPoint created
  • Retrieve all contained things inside an Iteration
  • Filter Things based on the ClassKind and on Category ShortNames

Copy link
Member

@samatstariongroup samatstariongroup left a comment

Choose a reason for hiding this comment

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

code looks very good, but please limnit the use of static classes and use dependency injection

/// <summary>
/// Gets or sets a collection of <see cref="Category"/>s shortname to used during the cherry picking request
/// </summary>
IEnumerable<string> CategoriesShortName { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

i doubt using shortnames wil work, they cannot be guaranteed to be unique accross the chain of RDLs. Please refactor to use Guids, feel free to use shortguids

return invalidRequest.WithStatusCode(HttpStatusCode.BadRequest);
}

var cherryPickedThings = CherryPickHelper.CherryPick(resourceResponse, this.RequestUtils.QueryParameters.ClassKinds, this.RequestUtils.QueryParameters.CategoriesShortName)
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be refactored to use the injected interface and will help when doing unit testing, it can then be mocked

/// <summary>
/// Helper for the cherry picking features
/// </summary>
public static class CherryPickHelper
Copy link
Member

Choose a reason for hiding this comment

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

please refactor to an injectable service.

/// <summary>
/// Helper class that provide capabilities on retrieving contained <see cref="Thing"/> or container <see cref="Thing"/>
/// </summary>
public static class ContainmentHelper
Copy link
Member

Choose a reason for hiding this comment

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

please refactor to injectable service

{
Logger.Info(this.ConstructLog($"{requestToken} started"));
HttpRequestHelper.ValidateSupportedQueryParameter(this.Request, this.RequestUtils, SupportedGetQueryParameters);

Copy link
Member

Choose a reason for hiding this comment

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

i think that we should verify that the caller has permissions to request the classkind before we process the request. If the classkind does not have at leas READ, we should exit here and return a 404 not allowed. I want to make sure we do not create a backdoor here.

@samatstariongroup
Copy link
Member

please add unit tests to keep coverage to at least the current value or better. Core product, cannot accept code without coverage

Copy link
Contributor

@lxatstariongroup lxatstariongroup left a comment

Choose a reason for hiding this comment

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

I agree with Sam's comments. The rest looks good to me.

@antoineatstariongroup
Copy link
Contributor Author

@samatrhea Included your change requests and created unit tests for Services.

@antoineatstariongroup antoineatstariongroup merged commit 07e09d1 into development Jun 16, 2023
@antoineatstariongroup antoineatstariongroup deleted the feat/GH272-cherry-picking branch June 16, 2023 07:23
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.

Enable CherryPicking with Category filtering
3 participants