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

refactor(specs): new predict segment condition syntax #1202

Merged
merged 27 commits into from
Feb 13, 2023

Conversation

bengreenbank
Copy link
Contributor

@bengreenbank bengreenbank commented Dec 28, 2022

🧭 What and Why

Changing the Predict segment syntax from a string to an object that follows the proposed specification.

🎟 JIRA Ticket: PRED-921
https://algolia.atlassian.net/browse/DI-764

Changes included:

  • Add version to segment object
  • Add new conditions format to segment object

Dependencies

Do not merge until the API supports the new format. Even if the PR below is merged the changes may not have been deployed to production.

https://github.com/algolia/predict-api/pull/63

@bengreenbank bengreenbank self-assigned this Dec 28, 2022
@netlify
Copy link

netlify bot commented Dec 28, 2022

Deploy Preview for api-clients-automation ready!

Name Link
🔨 Latest commit 8d5f22c
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/63ea27f176c71c00084e45a6
😎 Deploy Preview https://deploy-preview-1202--api-clients-automation.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@algolia-bot
Copy link
Collaborator

algolia-bot commented Dec 28, 2022

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.
You can still access the code generated on main via this commit.

@bengreenbank bengreenbank marked this pull request as ready for review February 10, 2023 11:31
@bengreenbank bengreenbank requested a review from a team as a code owner February 10, 2023 11:31
@bengreenbank
Copy link
Contributor Author

Do not merge yet. See 'Dependencies' heading in the PR description

Fluf22
Fluf22 previously approved these changes Feb 10, 2023
Copy link
Contributor

@Fluf22 Fluf22 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

specs/predict/responses/Segment.yml Outdated Show resolved Hide resolved
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

great for the spec, mostly wondering something for the API consistency

Comment on lines +328 to +338
segmentFilterOperatorNumerical:
description: The operator used on the numerical filter value.
type: string
default: =
enum:
- =
- '!='
- '>'
- '>='
- <
- <=
Copy link
Member

Choose a reason for hiding this comment

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

not related to this PR but wouldn't you want your API to have the same convention for operators? I see that in some places you use AND/OR, here we use mathematical operators but below (in segmentFilterProbability) we use an other form

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We tried to use < and > as object keys for segmentFilterProbability but the spec didn't allow it. So here we use some aliases.

Is there a symbol operator for OR? Of course AND can be +.

Copy link
Member

Choose a reason for hiding this comment

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

segmentFilterProbability is out of date, no?

properties:
lt:
type: number
lte:
type: number
gt:
type: number
gte:
type: number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These textual representations (lt, lte etc) actually resolve as symbols <, <=. See e1c61be

Is this what you are referring to?

Copy link
Member

Choose a reason for hiding this comment

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

I was not speaking for the generation, indeed the workaround make it work, but for the consistency of the API it might be great to consider having the same operator convention for each parameters. For example, every comparison could be made with: lt lte gt gte eq neq and or

Copy link
Member

Choose a reason for hiding this comment

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

(btw I don't think it's a discussion for this PR it can still move on!)

shortcuts
shortcuts previously approved these changes Feb 13, 2023
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

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

my comment is non blocking I'm just curious

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

Nice !

specs/predict/responses/Segment.yml Show resolved Hide resolved
shortcuts
shortcuts previously approved these changes Feb 13, 2023
"name": "predictions.order_value",
"filters": [
{
"operator": ">",
Copy link
Member

Choose a reason for hiding this comment

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

you'd need to update those tests

@@ -120,10 +120,33 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo

@Override
public String toEnumVarName(String value, String datatype) {
if ("String".equals(datatype) && !value.matches("[A-Z0-9_]+")) {
// when it's not a string, we don't want to change the name of the variable generated
Copy link
Member

Choose a reason for hiding this comment

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

you can revert this commit if there's no more symbols!

This reverts commit b4d4849.
@shortcuts shortcuts merged commit d3aead8 into main Feb 13, 2023
@shortcuts shortcuts deleted the feat/predict/segment_syntax branch February 13, 2023 12:27
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.

None yet

6 participants