From 86981aef8b8efa8f7b1f383a0dcaff0159349df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ksel=20K=C3=BC=C3=A7=C3=BCk=C5=9Fahin?= Date: Thu, 16 Jan 2025 18:57:35 +0300 Subject: [PATCH] fix: rename lesserThan as lessThan to make it gramaticaly correct --- benchmarks/tests/aggs_benchmark_test.go | 2 +- benchmarks/tests/complex_benchmark_test.go | 2 +- .../tests/conditional_benchmark_test.go | 2 +- es/range.go | 12 +++++------ es/range_test.go | 20 +++++++++---------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/benchmarks/tests/aggs_benchmark_test.go b/benchmarks/tests/aggs_benchmark_test.go index 9e90137..086ea5a 100644 --- a/benchmarks/tests/aggs_benchmark_test.go +++ b/benchmarks/tests/aggs_benchmark_test.go @@ -16,7 +16,7 @@ func createAggsQuery() map[string]any { es.Term("type", "File"), es.Range("indexedAt"). GreaterThan("2020-06-01"). - LesserThanOrEqual("now"), + LessThanOrEqual("now"), ). MustNot( es.Exists("file.name"), diff --git a/benchmarks/tests/complex_benchmark_test.go b/benchmarks/tests/complex_benchmark_test.go index cccd943..a62af1c 100644 --- a/benchmarks/tests/complex_benchmark_test.go +++ b/benchmarks/tests/complex_benchmark_test.go @@ -15,7 +15,7 @@ func createComplexQuery(id int) map[string]any { Must( es.Range("partition"). GreaterThan(25). - LesserThanOrEqual(30), + LessThanOrEqual(30), es.Bool(). Should( es.Term("doc.id", id), diff --git a/benchmarks/tests/conditional_benchmark_test.go b/benchmarks/tests/conditional_benchmark_test.go index 064cddb..5a49b0c 100644 --- a/benchmarks/tests/conditional_benchmark_test.go +++ b/benchmarks/tests/conditional_benchmark_test.go @@ -15,7 +15,7 @@ func createConditionalQuery(items []int) map[string]any { Filter( es.Range("indexedAt"). GreaterThan("2021-01-01"). - LesserThanOrEqual("now"), + LessThanOrEqual("now"), es.Term("type", "File"), es.Terms("sector", 1, 2, 3), es.TermsFunc("id", items, func(key string, values []int) bool { diff --git a/es/range.go b/es/range.go index 2f509ea..2da30ee 100644 --- a/es/range.go +++ b/es/range.go @@ -48,7 +48,7 @@ func (r rangeType) delete(key string) rangeType { return r } -// LesserThan sets the "lt" (less than) field for the range query. +// LessThan sets the "lt" (less than) field for the range query. // // This method specifies that the range query should match values that are less than // the provided value. It removes any existing "lte" (less than or equal to) field to ensure @@ -56,7 +56,7 @@ func (r rangeType) delete(key string) rangeType { // // Example usage: // -// r := Range("age").LesserThan(20) +// r := Range("age").LessThan(20) // // r now has an "lt" field set to 20 in the range query for the "age" field. // // Parameters: @@ -65,11 +65,11 @@ func (r rangeType) delete(key string) rangeType { // Returns: // // The updated rangeType object with the "lt" field set to the specified value. -func (r rangeType) LesserThan(lt any) rangeType { +func (r rangeType) LessThan(lt any) rangeType { return r.putInTheField("lt", lt).delete("lte") } -// LesserThanOrEqual sets the "lte" (less than or equal to) field for the range query. +// LessThanOrEqual sets the "lte" (less than or equal to) field for the range query. // // This method specifies that the range query should match values that are less than or equal // to the provided value. It removes any existing "lt" (less than) field to ensure that only @@ -77,7 +77,7 @@ func (r rangeType) LesserThan(lt any) rangeType { // // Example usage: // -// r := Range("age").LesserThanOrEqual(20) +// r := Range("age").LessThanOrEqual(20) // // r now has an "lte" field set to 20 in the range query for the "age" field. // // Parameters: @@ -86,7 +86,7 @@ func (r rangeType) LesserThan(lt any) rangeType { // Returns: // // The updated rangeType object with the "lte" field set to the specified value. -func (r rangeType) LesserThanOrEqual(lte any) rangeType { +func (r rangeType) LessThanOrEqual(lte any) rangeType { return r.putInTheField("lte", lte).delete("lt") } diff --git a/es/range_test.go b/es/range_test.go index 3407947..45a46d0 100644 --- a/es/range_test.go +++ b/es/range_test.go @@ -21,7 +21,7 @@ func Test_Range_should_add_range_field_when_inside_query(t *testing.T) { Must( es.Range("age"). GreaterThanOrEqual(10). - LesserThanOrEqual(20), + LessThanOrEqual(20), es.Term("language", "tr"), ), ) @@ -49,7 +49,7 @@ func Test_Range_should_create_json_with_range_field_inside_query(t *testing.T) { query := es.NewQuery( es.Range("age"). GreaterThanOrEqual(10). - LesserThanOrEqual(20), + LessThanOrEqual(20), ) // When Then @@ -58,22 +58,22 @@ func Test_Range_should_create_json_with_range_field_inside_query(t *testing.T) { assert.Equal(t, "{\"query\":{\"range\":{\"age\":{\"gte\":10,\"lte\":20}}}}", bodyJSON) } -func Test_Range_should_have_LesserThan_method(t *testing.T) { +func Test_Range_should_have_LessThan_method(t *testing.T) { // Given r := es.Range("age") // When Then assert.NotNil(t, r) - assert.NotNil(t, r.LesserThan) + assert.NotNil(t, r.LessThan) } -func Test_Range_should_have_LesserThanOrEqual_method(t *testing.T) { +func Test_Range_should_have_LessThanOrEqual_method(t *testing.T) { // Given r := es.Range("age") // When Then assert.NotNil(t, r) - assert.NotNil(t, r.LesserThanOrEqual) + assert.NotNil(t, r.LessThanOrEqual) } func Test_Range_should_have_GreaterThan_method(t *testing.T) { @@ -112,8 +112,8 @@ func Test_Range_lte_should_override_lt_and_vise_versa(t *testing.T) { // Given query := es.NewQuery( es.Range("age"). - LesserThan(11). - LesserThanOrEqual(23), + LessThan(11). + LessThanOrEqual(23), ) // When Then @@ -136,7 +136,7 @@ func Test_Range_Format_should_create_json_with_range_field_inside_query(t *testi query := es.NewQuery( es.Range("birth-date"). GreaterThanOrEqual("1990-01-01"). - LesserThanOrEqual("2024-04-12"). + LessThanOrEqual("2024-04-12"). Format("yyyy-MM-dd"), ) @@ -161,7 +161,7 @@ func Test_Range_Boost_should_create_json_with_range_field_inside_query(t *testin query := es.NewQuery( es.Range("partition"). GreaterThan(112). - LesserThan(765). + LessThan(765). Boost(3.2), )