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

V1.8.0 #74

Closed
wants to merge 2 commits into from
Closed

V1.8.0 #74

wants to merge 2 commits into from

Conversation

enjinabner
Copy link
Contributor

@enjinabner enjinabner commented Jun 11, 2024

PR Type

Enhancement, Tests


Description

  • Added singleUseCodes filter to GetClaims query and updated validation rules.
  • Created HasSingleUseCodeScope trait for handling single-use code scope.
  • Integrated HasSingleUseCodeScope trait in BeamClaim model.
  • Added validation to prevent claiming beams from multi-use codes when set to single-use.
  • Added tests for singleUseCodes filter in GetClaims query.
  • Added test for claiming single-use beam from multi-use code.
  • Updated tests to handle invalid parameters and too many codes.
  • Added fix script to composer scripts.
  • Added singleUseCodes argument to GraphQL GetClaims query.

Changes walkthrough 📝

Relevant files
Documentation
1 files
mutation.php
Add description for `single_use_code` argument in mutation.

lang/en/mutation.php

  • Added description for single_use_code argument in claim_beam mutation.

  • +1/-0     
    Enhancement
    5 files
    GetClaimsQuery.php
    Add `singleUseCodes` filter and update validation rules. 

    src/GraphQL/Queries/GetClaimsQuery.php

  • Added singleUseCodes filter to GetClaims query.
  • Updated validation rules for codes and singleUseCodes.
  • Modified query resolution to handle singleUseCodes.
  • +9/-2     
    BeamClaim.php
    Integrate `HasSingleUseCodeScope` trait in `BeamClaim` model.

    src/Models/Laravel/BeamClaim.php

  • Added HasSingleUseCodeScope trait to BeamClaim model.
  • Reordered traits for better readability.
  • +6/-5     
    HasSingleUseCodeScope.php
    Create `HasSingleUseCodeScope` trait.                                       

    src/Models/Laravel/Traits/HasSingleUseCodeScope.php

  • Created HasSingleUseCodeScope trait for handling single-use code
    scope.
  • +29/-0   
    CanClaim.php
    Add validation for single-use beam claims.                             

    src/Rules/CanClaim.php

  • Added validation to prevent claiming beams from multi-use codes when
    set to single-use.
  • +4/-0     
    GetClaims.graphql
    Add `singleUseCodes` argument to GraphQL query.                   

    tests/Feature/GraphQL/Resources/GetClaims.graphql

    • Added singleUseCodes argument to GetClaims query.
    +2/-0     
    Tests
    2 files
    ClaimBeamTest.php
    Add test for single-use beam claim validation.                     

    tests/Feature/GraphQL/Mutations/ClaimBeamTest.php

    • Added test for claiming single-use beam from multi-use code.
    +17/-0   
    GetClaimsTest.php
    Add tests for `singleUseCodes` filter and validation.       

    tests/Feature/GraphQL/Queries/GetClaimsTest.php

  • Added tests for singleUseCodes filter in GetClaims query.
  • Updated tests to handle invalid parameters and too many codes.
  • +43/-2   
    Configuration changes
    1 files
    composer.json
    Add `fix` script to composer.                                                       

    composer.json

    • Added fix script to composer scripts.
    +1/-0     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review [1-5]

    3

    🧪 Relevant tests

    Yes

    🔒 Security concerns

    No

    ⚡ Key issues to review

    Possible Bug:
    The HasSingleUseCodeScope trait uses a decryption method without handling potential decryption failures robustly. Consider adding error handling or validation before decryption to ensure stability.

    Performance Concern:
    The addition of new fields and validation rules in GetClaimsQuery.php might impact the performance of the query, especially with large datasets. It's recommended to benchmark these changes to ensure they meet performance expectations.

    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add nullability check to 'singleUseCodes' to handle potential null inputs

    It's recommended to add a null check for the 'singleUseCodes' before applying array
    operations and decryption to prevent potential errors when the input is null.

    src/GraphQL/Queries/GetClaimsQuery.php [59-62]

     'singleUseCodes' => [
         'type' => GraphQL::type('[String]'),
         'description' => __('enjin-platform-beam::mutation.claim_beam.args.single_use_code'),
    -    'rules' => ['prohibits:ids', 'array', 'max:100'],
    +    'rules' => ['prohibits:ids', 'array', 'max:100', 'nullable'],
     ],
     
    Suggestion importance[1-10]: 8

    Why: Adding a nullability check for 'singleUseCodes' is a good practice to prevent potential errors when the input is null. This improves the robustness of the code by ensuring that null inputs are handled gracefully.

    8

    @enjinabner enjinabner closed this Jun 11, 2024
    @leonardocustodio leonardocustodio deleted the v1.8.0 branch June 11, 2024 18:20
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Development

    Successfully merging this pull request may close these issues.

    2 participants