Skip to content

Commit

Permalink
fix: rename lesserThan as lessThan to make it gramaticaly correct
Browse files Browse the repository at this point in the history
  • Loading branch information
GokselKUCUKSAHIN committed Jan 16, 2025
1 parent 14d1eac commit 86981ae
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion benchmarks/tests/aggs_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/tests/complex_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/tests/conditional_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions es/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ 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
// that only one type of range condition is applied.
//
// 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:
Expand All @@ -65,19 +65,19 @@ 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
// one type of range condition is applied.
//
// 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:
Expand All @@ -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")
}

Expand Down
20 changes: 10 additions & 10 deletions es/range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
)
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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"),
)

Expand All @@ -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),
)

Expand Down

0 comments on commit 86981ae

Please sign in to comment.