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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(specs): update Predict Segment operators to textual format #1316

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,6 @@ public String toEnumVarName(String value, String datatype) {
return super.toEnumVarName(value, datatype);
}

// predict has some enums that are operators, we internally convert them to prevent wrong
// assumptions from the generator/templates.
switch (value) {
case "<":
return "LT";
case ">":
return "GT";
case "=":
return "EQ";
case "<=":
return "LTE";
case ">=":
return "GTE";
case "!=":
return "NEQ";
}

if (!value.matches("[A-Z0-9_]+")) {
// convert camelCase77String to CAMEL_CASE_77_STRING
return value.replaceAll("-", "_").replaceAll("(.+?)([A-Z]|[0-9])", "$1_$2").toUpperCase(Locale.ROOT);
Expand Down
28 changes: 14 additions & 14 deletions specs/predict/responses/Segment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,34 +305,34 @@ segmentPropertyFilterValue:
segmentFilterOperatorBoolean:
description: The operator used on the boolean filter value.
type: string
default: =
default: 'EQ'
enum:
- =
- '!='
- 'EQ'
- 'NEQ'

segmentFilterOperatorNumerical:
description: The operator used on the numerical filter value.
type: string
default: =
default: 'EQ'
enum:
- =
- '!='
- '>'
- '>='
- <
- <=
- 'EQ'
- 'NEQ'
- 'GT'
- 'GTE'
- 'LT'
- 'LTE'

segmentFilterProbability:
description: Probability of the filter.
type: object
minProperties: 1
maxProperties: 2
properties:
lt:
LT:
type: number
lte:
LTE:
type: number
gt:
GT:
type: number
gte:
GTE:
type: number
53 changes: 51 additions & 2 deletions tests/CTS/methods/requests/predict/createSegment.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "predictions.order_value",
"filters": [
{
"operator": ">",
"operator": "GT",
"value": 200
}
]
Expand All @@ -30,7 +30,7 @@
"name": "predictions.order_value",
"filters": [
{
"operator": ">",
"operator": "GT",
"value": 200
}
]
Expand All @@ -39,5 +39,54 @@
}
}
}
},
{
"testName": "create segment with filter probability",
"parameters": {
"name": "segment1",
"conditions": {
"operator": "AND",
"operands": [
{
"name": "predictions.affinities.color",
"filters": [
{
"operator": "EQ",
"value": "red",
"probability": {
"GTE": 0.5,
"LTE": 1
}
}
]
}
]
}
},
"request": {
"path": "/1/segments",
"method": "POST",
"body": {
"name": "segment1",
"conditions": {
"operator": "AND",
"operands": [
{
"name": "predictions.affinities.color",
"filters": [
{
"operator": "EQ",
"value": "red",
"probability": {
"GTE": 0.5,
"LTE": 1
}
}
]
}
]
}
}
}
}
]
58 changes: 54 additions & 4 deletions tests/CTS/methods/requests/predict/updateSegment.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"name": "predictions.order_value",
"filters": [
{
"operator": ">",
"operator": "GT",
"value": 200
}
]
Expand All @@ -47,7 +47,7 @@
"name": "predictions.order_value",
"filters": [
{
"operator": ">",
"operator": "GT",
"value": 200
}
]
Expand All @@ -70,7 +70,7 @@
"name": "predictions.order_value",
"filters": [
{
"operator": ">",
"operator": "GT",
"value": 200
}
]
Expand All @@ -91,7 +91,7 @@
"name": "predictions.order_value",
"filters": [
{
"operator": ">",
"operator": "GT",
"value": 200
}
]
Expand All @@ -100,5 +100,55 @@
}
}
}
},
{
"testName": "updateSegment with filter probability",
"parameters": {
"segmentID": "segment1",
"updateSegmentParams": {
"conditions": {
"operator": "AND",
"operands": [
{
"name": "predictions.affinities.color",
"filters": [
{
"operator": "EQ",
"value": "red",
"probability": {
"GTE": 0.5,
"LTE": 1
}
}
]
}
]
}
}
},
"request": {
"path": "/1/segments/segment1",
"method": "POST",
"body": {
"conditions": {
"operator": "AND",
"operands": [
{
"name": "predictions.affinities.color",
"filters": [
{
"operator": "EQ",
"value": "red",
"probability": {
"GTE": 0.5,
"LTE": 1
}
}
]
}
]
}
}
}
}
]