Skip to content

Commit

Permalink
Merge pull request #873 from 1AhmedYasser/revert-865-861-rules-details
Browse files Browse the repository at this point in the history
Revert "861 Improve Rules Details page"
  • Loading branch information
varmoh authored Feb 13, 2025
2 parents 6dddcc9 + 68cf7af commit b248586
Show file tree
Hide file tree
Showing 28 changed files with 389 additions and 534 deletions.
2 changes: 1 addition & 1 deletion DSL/DMapper/hbs/get_entities.handlebars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"entities": [
{{#each data.hits}}
{{#each this.fields.filtered_items.[0].response}}
{{#each this.fields.filtered_entities}}
{
"id": "{{{ this }}}",
"name": "{{{ this }}}"
Expand Down
11 changes: 0 additions & 11 deletions DSL/DMapper/hbs/get_intent_ids.handlebars

This file was deleted.

7 changes: 7 additions & 0 deletions DSL/DMapper/hbs/get_intents.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"intents": [
{{#each hits}}
"{{_source.intent}}"{{#unless @last}},{{/unless}}
{{/each}}
]
}
3 changes: 1 addition & 2 deletions DSL/DMapper/hbs/get_responses_dependencies.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@
]
}{{#unless @last}},{{/unless}}
{{/each}}
],
"totalCount": {{totalCount}}
]
}
3 changes: 1 addition & 2 deletions DSL/OpenSearch/deploy-opensearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ curl -H "Content-Type: application/x-ndjson" -X PUT "$URL/intents" -ku "$AUTH" -
if $MOCK_ALLOWED; then curl -H "Content-Type: application/x-ndjson" -X PUT "$URL/intents/_bulk" -ku "$AUTH" --data-binary "@mock/intents.json"; fi
curl -L -X POST "$URL/_scripts/intent-with-name" -H 'Content-Type: application/json' --data-binary "@templates/intent-with-name.json"
curl -L -X POST "$URL/_scripts/intents-with-examples-count" -H 'Content-Type: application/json' --data-binary "@templates/intents-with-examples-count.json"
curl -L -X POST "$URL/_scripts/intents-with-pagination" -H 'Content-Type: application/json' -H 'Cookie: customJwtCookie=test' --data-binary "@templates/intents-with-pagination.json"

# rules
curl -XDELETE "$URL/rules?ignore_unavailable=true" -u "$AUTH" --insecure
Expand Down Expand Up @@ -86,8 +85,8 @@ if $MOCK_ALLOWED; then curl -H "Content-Type: application/x-ndjson" -X PUT "$URL
#Domain
curl -XDELETE "$URL/domain?ignore_unavailable=true" -u "$AUTH" --insecure
curl -H "Content-Type: application/x-ndjson" -X PUT "$URL/domain" -ku "$AUTH" --data-binary "@fieldMappings/domain.json"
curl -L -X POST "$URL/_scripts/domain-objects-with-pagination" -H 'Content-Type: application/json' -H 'Cookie: customJwtCookie=test' --data-binary "@templates/domain-objects-with-pagination.json"
if $MOCK_ALLOWED; then curl -H "Content-Type: application/x-ndjson" -X PUT "$URL/domain/_bulk" -ku "$AUTH" --data-binary "@mock/domain.json"; fi
curl -L -X POST "$URL/_scripts/entities-with-pagination" -H 'Content-Type: application/json' -H 'Cookie: customJwtCookie=test' --data-binary "@templates/entities-with-pagination.json"

#Config
curl -XDELETE "$URL/config?ignore_unavailable=true" -u "$AUTH" --insecure
Expand Down
6 changes: 0 additions & 6 deletions DSL/OpenSearch/templates/domain-objects-with-pagination.json

This file was deleted.

6 changes: 6 additions & 0 deletions DSL/OpenSearch/templates/entities-with-pagination.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"script": {
"lang": "mustache",
"source": "{\"query\":{\"term\":{\"_id\":\"entities\"}},\"script_fields\":{\"filtered_entities\":{\"script\":{\"lang\":\"painless\",\"source\":\"def entities = params._source.entities; def searchTerm = '{{filter}}'; int from = {{from}}; int size = {{size}}; def filtered = entities.findAll(entity -> entity.toLowerCase().contains(searchTerm.toLowerCase())); int start = (int)Math.min(from, filtered.size()); int end = (int)Math.min(from + size, filtered.size()); return filtered.subList(start, end);\"}}}}"
}
}
25 changes: 0 additions & 25 deletions DSL/OpenSearch/templates/intents-with-pagination.json

This file was deleted.

2 changes: 1 addition & 1 deletion DSL/OpenSearch/templates/responses-with-pagination.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"script": {
"lang": "mustache",
"source": "{\"query\":{\"term\":{\"_id\":\"responses\"}},\"script_fields\":{\"filtered_responses\":{\"script\":{\"lang\":\"painless\",\"source\":\"def responses = params._source.responses; def searchTerm = '{{filter}}'.toLowerCase(); int from = {{from}}; int size = {{size}}; def filteredResponses = new HashMap(); for (def entry : responses.entrySet()) { def responseName = entry.getKey(); if (searchTerm == '' || responseName.toLowerCase().contains(searchTerm)) { filteredResponses.put(responseName, entry.getValue()); } } int start = (int)Math.min(from, filteredResponses.size()); int end = (int)Math.min(from + size, filteredResponses.size()); def paginatedResponses = new HashMap(); int counter = 0; for (def entry : filteredResponses.entrySet()) { if (counter >= start && counter < end) { paginatedResponses.put(entry.getKey(), entry.getValue()); } counter++; } return paginatedResponses;\"}},\"total_count\":{\"script\":{\"lang\":\"painless\",\"source\":\"def responses = params._source.responses; def searchTerm = '{{filter}}'.toLowerCase(); def filteredResponses = new HashMap(); for (def entry : responses.entrySet()) { def responseName = entry.getKey(); if (searchTerm == '' || responseName.toLowerCase().contains(searchTerm)) { filteredResponses.put(responseName, entry.getValue()); } } return (int)filteredResponses.size();\"}}}}"
"source": "{\"query\":{\"term\":{\"_id\":\"responses\"}},\"script_fields\":{\"filtered_responses\":{\"script\":{\"lang\":\"painless\",\"source\":\"def responses = params._source.responses; def searchTerm = '{{filter}}'; int from = {{from}}; int size = {{size}}; def filteredResponses = new HashMap(); for (def entry : responses.entrySet()) { def responseName = entry.getKey(); if (searchTerm == '' || responseName.toLowerCase().contains(searchTerm.toLowerCase())) { filteredResponses.put(responseName, entry.getValue()); } } int start = (int)Math.min(from, filteredResponses.size()); int end = (int)Math.min(from + size, filteredResponses.size()); def result = new HashMap(); int counter = 0; for (def entry : filteredResponses.entrySet()) { if (counter >= start && counter < end) { result.put(entry.getKey(), entry.getValue()); } counter++; } return result;\"}}}}"
}
}
8 changes: 2 additions & 6 deletions DSL/Ruuter.private/GET/rasa/entities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ getEntities:
args:
url: "[#TRAINING_OPENSEARCH]/domain/_search/template"
body:
id: "domain-objects-with-pagination"
params:
type: "entities"
filter: ${incoming.params.filter}
from: ${incoming.params.from}
size: ${incoming.params.size}
id: "entities-with-pagination"
params: ${incoming.params}
result: getEntitiesResult

mapEntitiesData:
Expand Down
36 changes: 0 additions & 36 deletions DSL/Ruuter.private/GET/rasa/forms-list.yml

This file was deleted.

44 changes: 0 additions & 44 deletions DSL/Ruuter.private/GET/rasa/intent-ids.yml

This file was deleted.

30 changes: 30 additions & 0 deletions DSL/Ruuter.private/GET/rasa/intents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
declaration:
call: declare
version: 0.1
description: "Decription placeholder for 'INTENTS'"
method: get
accepts: json
returns: json
namespace: training

getIntents:
call: http.get
args:
url: "[#TRAINING_OPENSEARCH]/intents/_search?size=10000"
result: getIntentsResult

mapIntentsData:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_intents"
headers:
type: 'json'
body:
hits: ${getIntentsResult.response.body.hits.hits}
result: intentsData
next: returnSuccess

returnSuccess:
return: ${intentsData.response.body.intents}
wrapper: false
next: end
76 changes: 76 additions & 0 deletions DSL/Ruuter.private/GET/rasa/responses-list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
declaration:
call: declare
version: 0.1
description: "Description placeholder for 'RESPONSES-LIST'"
method: get
accepts: json
returns: json
namespace: training
params:
- field: filter
type: string
description: "Query string"
- field: from
type: string
description: "Item number"
- field: size
type: string
description: "Page size"

getResponses:
call: http.post
args:
url: "[#TRAINING_OPENSEARCH]/domain/_search/template"
body:
id: "responses-with-pagination"
params: ${incoming.params}
result: getResponsesResult

mapResponsesNames:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_responses_names"
headers:
type: "json"
body:
data: ${getResponsesResult.response.body.hits.hits[0].fields.filtered_responses[0]}
result: responsesNames

getStories:
call: http.post
args:
url: "[#TRAINING_OPENSEARCH]/stories/_search/template"
body:
id: "stories-by-responses"
params:
responses: "${responsesNames.response.body}"
size: 1000
result: getStoriesResult

getRules:
call: http.post
args:
url: "[#TRAINING_OPENSEARCH]/rules/_search/template"
body:
id: "rules-by-responses"
params:
responses: "${responsesNames.response.body}"
size: 1000
result: getRulesResult

mapResponsesData:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_responses_dependencies"
headers:
type: "json"
body:
rules: ${getRulesResult.response.body.hits.hits}
stories: ${getStoriesResult.response.body.hits.hits}
responses: ${getResponsesResult.response.body.hits.hits[0].fields.filtered_responses[0]}
result: responsesData

returnSuccess:
return: ${responsesData.response.body}
wrapper: false
next: end
63 changes: 8 additions & 55 deletions DSL/Ruuter.private/GET/rasa/responses.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,30 @@
declaration:
call: declare
version: 0.1
description: "Description placeholder for 'responses'"
description: "Decription placeholder for 'RESPONSES'"
method: get
accepts: json
returns: json
namespace: training
params:
- field: filter
type: string
description: "Query string"
- field: from
type: string
description: "Item number"
- field: size
type: string
description: "Page size"

getResponses:
call: http.post
call: http.get
args:
url: "[#TRAINING_OPENSEARCH]/domain/_search/template"
body:
id: "responses-with-pagination"
params: ${incoming.params}
url: "[#TRAINING_OPENSEARCH]/domain/_search?size=10000"
result: getResponsesResult

mapResponsesNames:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_responses_names"
headers:
type: "json"
body:
data: ${getResponsesResult.response.body.hits.hits[0].fields.filtered_responses[0]}
result: responsesNames

getStories:
call: http.post
args:
url: "[#TRAINING_OPENSEARCH]/stories/_search/template"
body:
id: "stories-by-responses"
params:
responses: "${responsesNames.response.body}"
size: 1000
result: getStoriesResult

getRules:
call: http.post
args:
url: "[#TRAINING_OPENSEARCH]/rules/_search/template"
body:
id: "rules-by-responses"
params:
responses: "${responsesNames.response.body}"
size: 1000
result: getRulesResult

mapResponsesData:
call: http.post
args:
url: "[#TRAINING_DMAPPER]/hbs/training/get_responses_dependencies"
url: "[#TRAINING_DMAPPER]/hbs/training/get_responses"
headers:
type: "json"
type: 'json'
body:
rules: ${getRulesResult.response.body.hits.hits}
stories: ${getStoriesResult.response.body.hits.hits}
responses: ${getResponsesResult.response.body.hits.hits[0].fields.filtered_responses[0]}
totalCount: ${getResponsesResult.response.body.hits.hits[0].fields.total_count[0]}
hits: ${getResponsesResult.response.body.hits.hits}
result: responsesData
next: returnSuccess

returnSuccess:
return: ${responsesData.response.body}
return: ${responsesData.response.body.responses}
wrapper: false
next: end
Loading

0 comments on commit b248586

Please sign in to comment.