Skip to content

Commit

Permalink
ref(search): normalize parsed values (#69198)
Browse files Browse the repository at this point in the history
Normalize parsed values. Durations to ms, sizes to bytes, numbers to
spoiler alert (numbers), dates to dates and bools to "duh" bools

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
  • Loading branch information
JonasBa and getsantry[bot] authored Apr 18, 2024
1 parent e0f7ffb commit c418650
Show file tree
Hide file tree
Showing 22 changed files with 196 additions and 142 deletions.
2 changes: 1 addition & 1 deletion fixtures/search-syntax/aggregate_duration_filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"type": "valueDuration",
"value": "500",
"unit": "s",
"parsed": {"value": 500, "unit": "s"}
"parsed": {"value": 500000}
}
},
{"type": "spaces", "value": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"type": "valueDuration",
"value": "2",
"unit": "m",
"parsed": {"value": 2, "unit": "m"}
"parsed": {"value": 120000}
}
},
{"type": "spaces", "value": ""}
Expand Down
4 changes: 0 additions & 4 deletions fixtures/search-syntax/aggregate_rel_time_filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
"sign": "+",
"unit": "d",
"parsed": {
"sign": "+",
"unit": "d",
"value": "2017-10-24T02:41:20.000Z"
}
}
Expand Down Expand Up @@ -52,8 +50,6 @@
"sign": "-",
"unit": "w",
"parsed": {
"sign": "-",
"unit": "w",
"value": "2017-10-03T02:41:20.000Z"
}
}
Expand Down
2 changes: 1 addition & 1 deletion fixtures/search-syntax/boolean_filter_passthrough.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "valueNumber",
"value": "1",
"unit": null,
"parsed": {"value": 1, "unit": null}
"parsed": {"value": 1}
}
},
{"type": "spaces", "value": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"type": "valueDuration",
"value": "3.3",
"unit": "s",
"parsed": {"value": 3.3, "unit": "s"}
"parsed": {"value": 3300}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -77,7 +77,7 @@
"type": "valueDuration",
"value": "3.3",
"unit": "s",
"parsed": {"value": 3.3, "unit": "s"}
"parsed": {"value": 3300}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -119,7 +119,7 @@
"type": "valueDuration",
"value": "3.3",
"unit": "s",
"parsed": {"value": 3.3, "unit": "s"}
"parsed": {"value": 3300}
}
},
{"type": "spaces", "value": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"type": "valueDuration",
"value": "3.3",
"unit": "s",
"parsed": {"value": 3.3, "unit": "s"}
"parsed": {"value": 3300}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -77,7 +77,7 @@
"type": "valueDuration",
"value": "3.3",
"unit": "s",
"parsed": {"value": 3.3, "unit": "s"}
"parsed": {"value": 3300}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -119,7 +119,7 @@
"type": "valueDuration",
"value": "3.3",
"unit": "s",
"parsed": {"value": 3.3, "unit": "s"}
"parsed": {"value": 3300}
}
},
{"type": "spaces", "value": ""}
Expand Down
4 changes: 2 additions & 2 deletions fixtures/search-syntax/duration_filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "valueDuration",
"value": "500",
"unit": "s",
"parsed": {"value": 500, "unit": "s"}
"parsed": {"value": 500000}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -33,7 +33,7 @@
"type": "valueDuration",
"value": "500",
"unit": "s",
"parsed": {"value": 500, "unit": "s"}
"parsed": {"value": 500000}
}
},
{"type": "spaces", "value": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"type": "valueDuration",
"value": "2",
"unit": "m",
"parsed": {"value": 2, "unit": "m"}
"parsed": {"value": 120000}
}
},
{"type": "spaces", "value": ""}
Expand Down
6 changes: 3 additions & 3 deletions fixtures/search-syntax/duration_measurements_filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "valueDuration",
"value": "1.5",
"unit": "s",
"parsed": {"value": 1.5, "unit": "s"}
"parsed": {"value": 1500}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -33,7 +33,7 @@
"type": "valueDuration",
"value": "1.5",
"unit": "s",
"parsed": {"value": 1.5, "unit": "s"}
"parsed": {"value": 1500}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -53,7 +53,7 @@
"type": "valueDuration",
"value": "1.5",
"unit": "s",
"parsed": {"value": 1.5, "unit": "s"}
"parsed": {"value": 1500}
}
},
{"type": "spaces", "value": ""}
Expand Down
6 changes: 3 additions & 3 deletions fixtures/search-syntax/duration_op_breakdowns_filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "valueDuration",
"value": "1.5",
"unit": "s",
"parsed": {"value": 1.5, "unit": "s"}
"parsed": {"value": 1500}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -33,7 +33,7 @@
"type": "valueDuration",
"value": "1.5",
"unit": "s",
"parsed": {"value": 1.5, "unit": "s"}
"parsed": {"value": 1500}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -53,7 +53,7 @@
"type": "valueDuration",
"value": "1.5",
"unit": "s",
"parsed": {"value": 1.5, "unit": "s"}
"parsed": {"value": 1500}
}
},
{"type": "spaces", "value": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"type": "valueNumber",
"value": "3.1415",
"unit": null,
"parsed": {"value": 3.1415, "unit": null}
"parsed": {"value": 3.1415}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -69,7 +69,7 @@
"type": "valueNumber",
"value": "3.1415",
"unit": null,
"parsed": {"value": 3.1415, "unit": null}
"parsed": {"value": 3.1415}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -107,7 +107,7 @@
"type": "valueNumber",
"value": "3.1415",
"unit": null,
"parsed": {"value": 3.1415, "unit": null}
"parsed": {"value": 3.1415}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -145,7 +145,7 @@
"type": "valueNumber",
"value": "3",
"unit": "k",
"parsed": {"value": 3000, "unit": "k"}
"parsed": {"value": 3000}
}
},
{"type": "spaces", "value": ""}
Expand Down Expand Up @@ -183,7 +183,7 @@
"type": "valueNumber",
"value": "2",
"unit": "m",
"parsed": {"value": 2000000, "unit": "m"}
"parsed": {"value": 2000000}
}
},
{"type": "spaces", "value": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"value": "3.1415",
"unit": null,
"parsed": {
"unit": null,
"value": 3.1415
}
}
Expand Down Expand Up @@ -102,7 +101,6 @@
"value": "3.1415",
"unit": null,
"parsed": {
"unit": null,
"value": 3.1415
}
}
Expand Down Expand Up @@ -159,7 +157,6 @@
"value": "3.1415",
"unit": null,
"parsed": {
"unit": null,
"value": 3.1415
}
}
Expand Down Expand Up @@ -216,7 +213,6 @@
"value": "3",
"unit": "k",
"parsed": {
"unit": "k",
"value": 3000
}
}
Expand Down Expand Up @@ -274,8 +270,7 @@
"value": "2",
"unit": "m",
"parsed": {
"unit": "m",
"value": 2
"value": 120000
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions fixtures/search-syntax/numeric_filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"type": "valueNumber",
"value": "-500",
"unit": null,
"parsed": {"value": -500, "unit": null}
"parsed": {"value": -500}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -80,7 +80,7 @@
"type": "valueNumber",
"value": "500",
"unit": null,
"parsed": {"value": 500, "unit": null}
"parsed": {"value": 500}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -100,7 +100,7 @@
"type": "valueNumber",
"value": "500",
"unit": null,
"parsed": {"value": 500, "unit": null}
"parsed": {"value": 500}
}
},
{"type": "spaces", "value": ""}
Expand Down
3 changes: 1 addition & 2 deletions fixtures/search-syntax/numeric_filter_with_decimals.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"value": "3.1415",
"unit": null,
"parsed": {
"value": 3.1415,
"unit": null
"value": 3.1415
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions fixtures/search-syntax/numeric_filter_with_shorthand.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"type": "valueNumber",
"value": "3",
"unit": "k",
"parsed": {"value": 3000, "unit": "k"}
"parsed": {"value": 3000}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -33,7 +33,7 @@
"type": "valueNumber",
"value": "3",
"unit": "m",
"parsed": {"value": 3000000, "unit": "m"}
"parsed": {"value": 3000000}
}
},
{"type": "spaces", "value": ""}
Expand All @@ -53,7 +53,7 @@
"type": "valueNumber",
"value": "3",
"unit": "b",
"parsed": {"value": 3000000000, "unit": "b"}
"parsed": {"value": 3000000000}
}
},
{"type": "spaces", "value": ""}
Expand Down
Loading

0 comments on commit c418650

Please sign in to comment.