Skip to content

Commit

Permalink
Added delete intent token (#97)
Browse files Browse the repository at this point in the history
* WIP auto purge

* Remove unused function and redundant logging

The `numberWithoutExponent` function was removed as it was unused, and unnecessary logging in the search request was eliminated. These changes clean up the codebase and enhance maintainability.

* Handle 'Delete' operator in Elasticsearch query logic.

---------

Co-authored-by: Mathieu De Jesus <[email protected]>
  • Loading branch information
Ismail731404 and WatoLua authored Jan 3, 2025
1 parent d704de6 commit 2730965
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion elasticsearch/search_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ConvertFactToSearchRequestV8(f engine.Fact, ti time.Time, parameters map[st
}
request.Query = query

if f.Intent.Operator != engine.Select {
if f.Intent.Operator != engine.Select && f.Intent.Operator != engine.Delete {
mainAggName, mainAgg, err := buildElasticAgg(f.Intent)
if err != nil {
zap.L().Warn("buildElasticAgg", zap.Error(err))
Expand Down
1 change: 1 addition & 0 deletions engine/fragment_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var intentMap = map[IntentToken]func() *IntentFragment{
Select: func() *IntentFragment {
return &IntentFragment{"", Select, "", false}
},
Delete: func() *IntentFragment { return &IntentFragment{"", Delete, "", false} },
}

// GetIntentFragment search and return an intent fragment by it's name
Expand Down
4 changes: 4 additions & 0 deletions engine/token_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (
Max
// Select intent token
Select
// Delete
Delete
)

func (s IntentToken) String() string {
Expand All @@ -37,6 +39,7 @@ var intentToString = map[IntentToken]string{
Min: "min",
Max: "max",
Select: "select",
Delete: "delete",
}

var intentToID = map[string]IntentToken{
Expand All @@ -46,6 +49,7 @@ var intentToID = map[string]IntentToken{
"min": Min,
"max": Max,
"select": Select,
"delete": Delete,
}

// GetIntentToken search and return an intent token from the standard supported operator list
Expand Down
6 changes: 3 additions & 3 deletions expression/functions_date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ func TestFormatDate(t *testing.T) {
t.Error("formatDate should return abcd")
t.FailNow()
}
result, err = formatDate("2023-08-04T14:57:07.923", "2006-01-02 15:04:05")
if result != "2023-08-04 14:57:07" {
t.Error("formatDate should return abcd")
result, err = formatDate("2023-08-04T14:57:07.923", "2006-01-02")
if result != "2023-08-04" {
t.Error("formatDate should return 2023-08-04")
t.FailNow()
}
}
Expand Down
1 change: 0 additions & 1 deletion expression/gval.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ var (
gval.Function("average", average),
gval.Function("roundToDecimal", roundToDecimal),
gval.Function("safeDivide", safeDivide),
gval.Function("numberWithoutExponent", numberWithoutExponent),
gval.Function("abs", absoluteValue),
)

Expand Down

0 comments on commit 2730965

Please sign in to comment.