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

IBX-6620: Added image criterions rest input parsers #76

Merged
merged 3 commits into from
Nov 20, 2023

Conversation

ciastektk
Copy link
Contributor

@ciastektk ciastektk commented Oct 18, 2023

⚠️ Remove dev dependency!

Question Answer
JIRA issue IBX-6620
Type feature
Target version v4.6
BC breaks no
Tests pass yes/no
Doc needed yes

This PR adds new criteria parsers that allows to search images by REST.

Examples:

FileSize criterion:

Criterion to filter by image size.

min - Optional, minimum file size in MB
max - Optional maximum file size in MB

"ImageFileSizeCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "size": {
        "min": 0 
        "max": 2
    }
}

MimeType criterion:

Criterion to filter by image mime type.

type - string or array

"ImageMimeTypeCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "type": "image/jpeg"
}

OR

"ImageMimeTypeCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "type": [
        "image/jpeg",
        "image/png"
    ]
}

Orientation criterion:

Criterion to filter by image orientation.

orientation - string or array. Allowed orientation types: portrait, landscape, square.

"ImageMimeTypeCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "orientation": "portrait"
}

OR

"ImageMimeTypeCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "orientation": [
        "portrait",
        "landscape"
    ]
}

Dimensions criterion:

Composite criterion to filter by image dimensions.

Allowed criteria width, height. All criteria are optional.

min - Optional, minimum value in pixel
max - Optional, maximum value in pixel

"ImageDimensionsCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "width": {
        "min": 100
        "max": 1000
    },
    "height": {
        "min": 500
        "max": 1500
    }
}

Image criterion:

Composite criterion to filter by image attributes.

Allowed criteria mimeTypes, size,width, height,orientation. All criteria are optional.

min - Optional, minimum value in pixel or MB
max - Optional, maximum value in pixel or MB

"ImageCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "mimeTypes": [
        "image/png",
        "image/jpeg"
    ],
    "size": {
        "min": 0,
        "max": 2
    },
    "width": {
        "min": 100,
        "max": 1000
    },
    "height": {
        "min": 500,
        "max": 1500
    },
    "orientation": [
        "portrait",
        "landscape"
    ]
}

OR

"ImageCriterion": {
    "fieldDefIdentifier": "<field_definition_identifier>",
    "mimeTypes": "image/png",
    "size": {
        "min": 0,
        "max": 2
    },
    "width": {
        "min": 100,
        "max": 1000
    },
    "height": {
        "min": 500,
        "max": 1500
    },
    "orientation": "portrait"
}

TODO:

  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

@ciastektk ciastektk changed the title Ibx 6620 added rest input parsers IBX-6620: Added image criterions rest input parsers Oct 18, 2023
@ciastektk ciastektk force-pushed the ibx-6620-added-rest-input-parsers branch from a9de947 to a5b1fc4 Compare October 19, 2023 07:16
@ciastektk ciastektk force-pushed the ibx-6620-added-rest-input-parsers branch 2 times, most recently from fc311c1 to 2f68cda Compare October 19, 2023 12:24
@ciastektk ciastektk force-pushed the ibx-6620-added-rest-input-parsers branch from 2f68cda to a7acb74 Compare November 3, 2023 14:43
@ciastektk ciastektk marked this pull request as ready for review November 8, 2023 06:58
@ciastektk ciastektk requested a review from a team November 8, 2023 06:58
@ciastektk ciastektk added Feature New feature request Ready for review labels Nov 8, 2023
@ciastektk ciastektk requested a review from a team November 9, 2023 09:15
@konradoboza konradoboza requested a review from a team November 9, 2023 09:22
Copy link
Contributor

@Steveb-p Steveb-p left a comment

Choose a reason for hiding this comment

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

There are no associated tests. Can we get integration tests for those, on specific service level at least - with validation failures especially?

}

/**
* @param array<mixed> $data
Copy link
Contributor

Choose a reason for hiding this comment

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

Note

Optional.

You can use @phpstan-assert to inform static analysis about the expected shape of data after validation.

See https://phpstan.org/writing-php-code/narrowing-types#custom-type-checking-functions-and-methods for details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we discussed with the dev team, tests coverage will be added later.

@webhdx webhdx force-pushed the ibx-6620-added-rest-input-parsers branch from a7acb74 to bd450a6 Compare November 20, 2023 14:20
Copy link

sonarcloud bot commented Nov 20, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@webhdx webhdx merged commit a1d6cbe into main Nov 20, 2023
12 checks passed
@webhdx webhdx deleted the ibx-6620-added-rest-input-parsers branch November 20, 2023 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature request Ready for QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants