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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused fields from run result events #1293

Merged
merged 1 commit into from
Dec 2, 2024
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
10 changes: 3 additions & 7 deletions flows/actions/testdata/call_classifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Intent",
"value": "0",
"category": "Failure",
"input": "Hi everybody"
"category": "Failure"
}
],
"templates": [
Expand Down Expand Up @@ -179,7 +178,6 @@
"name": "Intent",
"value": "book_flight",
"category": "Success",
"input": "Hi everybody",
"extra": {
"intents": [
{
Expand Down Expand Up @@ -283,8 +281,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Intent",
"value": "0",
"category": "Failure",
"input": "Hi everybody"
"category": "Failure"
}
],
"templates": [
Expand Down Expand Up @@ -370,8 +367,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Intent",
"value": "0",
"category": "Failure",
"input": "Hi everybody"
"category": "Failure"
}
],
"templates": [
Expand Down
5 changes: 1 addition & 4 deletions flows/actions/testdata/call_resthook.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "My Result",
"value": "503",
"category": "Failure",
"input": "POST http://unavailable.com/"
"category": "Failure"
}
],
"webhook": {
Expand Down Expand Up @@ -411,7 +410,6 @@
"name": "My Result",
"value": "200",
"category": "Success",
"input": "POST http://temba.io/",
"extra": {
"ok": "true"
}
Expand Down Expand Up @@ -643,7 +641,6 @@
"name": "My Result",
"value": "503",
"category": "Failure",
"input": "POST http://unavailable.com/",
"extra": {
"errors": [
"service unavailable"
Expand Down
14 changes: 4 additions & 10 deletions flows/actions/testdata/call_webhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@
"name": "My Webhook",
"value": "200",
"category": "Success",
"input": "POST http://temba.io/",
"extra": {
"ok": true
}
Expand Down Expand Up @@ -391,8 +390,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "My Webhook",
"value": "200",
"category": "Success",
"input": "GET http://temba.io/"
"category": "Success"
}
],
"webhook": {
Expand Down Expand Up @@ -463,8 +461,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "My Webhook",
"value": "200",
"category": "Success",
"input": "GET http://temba.io/"
"category": "Success"
}
],
"webhook": {
Expand Down Expand Up @@ -537,7 +534,6 @@
"name": "My Webhook",
"value": "400",
"category": "Failure",
"input": "POST http://temba.io/",
"extra": {
"errors": [
"bad_request"
Expand Down Expand Up @@ -615,8 +611,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "My Webhook",
"value": "0",
"category": "Failure",
"input": "POST http://temba.io/"
"category": "Failure"
}
],
"webhook": {
Expand Down Expand Up @@ -693,8 +688,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "My Webhook",
"value": "200",
"category": "Failure",
"input": "GET http://temba.io/"
"category": "Failure"
}
],
"webhook": {
Expand Down
6 changes: 3 additions & 3 deletions flows/actions/testdata/send_broadcast.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@
"action": {
"type": "send_broadcast",
"uuid": "ad154980-7bf7-4ab8-8728-545fd6378912",
"urns": [
"tel:+1234567890"
],
"groups": [
{
"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
Expand All @@ -144,6 +141,9 @@
}
],
"contact_query": "name = \"Bob\"",
"urns": [
"tel:+1234567890"
],
"legacy_vars": [
"@(\"\")",
"@contact.fields.gender",
Expand Down
3 changes: 1 addition & 2 deletions flows/actions/testdata/set_run_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Preference",
"value": "yeah",
"category": "Yes",
"category_localized": "Si"
"category": "Yes"
}
],
"templates": [
Expand Down
6 changes: 3 additions & 3 deletions flows/actions/testdata/start_session.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@
"action": {
"type": "start_session",
"uuid": "ad154980-7bf7-4ab8-8728-545fd6378912",
"urns": [
"tel:+1234567890"
],
"groups": [
{
"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
Expand All @@ -291,6 +288,9 @@
}
],
"contact_query": "age > 20 OR gender = @fields.gender",
"urns": [
"tel:+1234567890"
],
"legacy_vars": [
"@(\"5129165834\")"
],
Expand Down
35 changes: 13 additions & 22 deletions flows/events/run_result_changed.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,25 @@ type PreviousResult struct {
Category string `json:"category"`
}

// RunResultChangedEvent events are created when a run result is saved. They contain not only
// the name, value and category of the result, but also the UUID of the node where
// the result was generated.
// RunResultChangedEvent events are created when a run result is changed.
//
// {
// "type": "run_result_changed",
// "created_on": "2006-01-02T15:04:05Z",
// "name": "Gender",
// "value": "m",
// "category": "Male",
// "category_localized": "Homme",
// "node_uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
// "input": "M"
// "category": "Male"
// }
//
// @event run_result_changed
type RunResultChangedEvent struct {
BaseEvent

Name string `json:"name" validate:"required"`
Value string `json:"value"`
Category string `json:"category"`
CategoryLocalized string `json:"category_localized,omitempty"`
Input string `json:"input,omitempty"`
Extra json.RawMessage `json:"extra,omitempty"`
Previous *PreviousResult `json:"previous,omitempty"`
Name string `json:"name" validate:"required"`
Value string `json:"value"`
Category string `json:"category"`
Extra json.RawMessage `json:"extra,omitempty"`
Previous *PreviousResult `json:"previous,omitempty"`
}

// NewRunResultChanged returns a new save result event for the passed in values
Expand All @@ -57,13 +50,11 @@ func NewRunResultChanged(result, prev *flows.Result) *RunResultChangedEvent {
}

return &RunResultChangedEvent{
BaseEvent: NewBaseEvent(TypeRunResultChanged),
Name: result.Name,
Value: result.Value,
Category: result.Category,
CategoryLocalized: result.CategoryLocalized,
Input: result.Input,
Extra: result.Extra,
Previous: p,
BaseEvent: NewBaseEvent(TypeRunResultChanged),
Name: result.Name,
Value: result.Value,
Category: result.Category,
Extra: result.Extra,
Previous: p,
}
}
3 changes: 1 addition & 2 deletions flows/resumes/testdata/dial.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"step_uuid": "9688d21d-95aa-4bed-afc7-f31b35731a3d",
"name": "Redirect",
"value": "answered",
"category": "Success",
"input": "answered"
"category": "Success"
}
],
"run_status": "completed",
Expand Down
3 changes: 1 addition & 2 deletions flows/resumes/testdata/msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"step_uuid": "9688d21d-95aa-4bed-afc7-f31b35731a3d",
"name": "Favorite Color",
"value": "red",
"category": "Red",
"input": "red"
"category": "Red"
}
],
"run_status": "completed",
Expand Down
3 changes: 1 addition & 2 deletions flows/routers/testdata/random.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Random Result",
"value": "1",
"category": "No",
"input": "0.3849275689214193"
"category": "No"
}
],
"localizables": [
Expand Down
12 changes: 4 additions & 8 deletions flows/routers/testdata/switch.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Favorite Color",
"value": "YES",
"category": "Yes",
"input": "YES!!"
"category": "Yes"
}
],
"templates": [
Expand Down Expand Up @@ -284,8 +283,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Is Member",
"value": "[]",
"category": "Other",
"input": "[]"
"category": "Other"
}
],
"templates": [
Expand Down Expand Up @@ -374,8 +372,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "In Group",
"value": "[]",
"category": "Other",
"input": "[]"
"category": "Other"
}
],
"templates": [
Expand Down Expand Up @@ -483,8 +480,7 @@
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c",
"name": "Favorite Color",
"value": "YES",
"category": "Yes",
"input": "YES!!"
"category": "Yes"
}
],
"templates": [
Expand Down
2 changes: 0 additions & 2 deletions test/testdata/runner/brochure.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
{
"category": "Not Empty",
"created_on": "2018-07-06T12:30:14.123456789Z",
"input": "Ryan Lewis",
"name": "Name",
"step_uuid": "5802813d-6c58-4292-8228-9728778b6c98",
"type": "run_result_changed",
Expand Down Expand Up @@ -333,7 +332,6 @@
{
"category": "Not Empty",
"created_on": "2018-07-06T12:30:14.123456789Z",
"input": "Ryan Lewis",
"name": "Name",
"step_uuid": "5802813d-6c58-4292-8228-9728778b6c98",
"type": "run_result_changed",
Expand Down
2 changes: 0 additions & 2 deletions test/testdata/runner/date_parse.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
{
"category": "Valid",
"created_on": "2018-07-06T12:30:13.123456789Z",
"input": "I was born on 1977.06.23 at 3:34 pm",
"name": "Birth Date",
"step_uuid": "8720f157-ca1c-432f-9c0b-2014ddc77094",
"type": "run_result_changed",
Expand Down Expand Up @@ -313,7 +312,6 @@
{
"category": "Valid",
"created_on": "2018-07-06T12:30:13.123456789Z",
"input": "I was born on 1977.06.23 at 3:34 pm",
"name": "Birth Date",
"step_uuid": "8720f157-ca1c-432f-9c0b-2014ddc77094",
"type": "run_result_changed",
Expand Down
2 changes: 0 additions & 2 deletions test/testdata/runner/default_result.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
{
"category": "All Responses",
"created_on": "2018-07-06T12:30:14.123456789Z",
"input": "Ryan Lewis",
"name": "Contact Name",
"step_uuid": "5802813d-6c58-4292-8228-9728778b6c98",
"type": "run_result_changed",
Expand Down Expand Up @@ -308,7 +307,6 @@
{
"category": "All Responses",
"created_on": "2018-07-06T12:30:14.123456789Z",
"input": "Ryan Lewis",
"name": "Contact Name",
"step_uuid": "5802813d-6c58-4292-8228-9728778b6c98",
"type": "run_result_changed",
Expand Down
Loading
Loading