Skip to content
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
18 changes: 1 addition & 17 deletions DSL/Resql/training/POST/add-intent.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
-- Insert new row for intent preserving existing status
-- This finds the latest version of the intent and creates a new row with preserved status
INSERT INTO intent (intent, created, status, isForService)
SELECT
:intent,
CURRENT_TIMESTAMP,
COALESCE(latest_intent.status, :status),
false
FROM (
-- Find the latest version of the specific intent
SELECT DISTINCT ON (intent)
intent,
status,
created
FROM intent
WHERE intent = :intent
ORDER BY intent, created DESC
) AS latest_intent;
VALUES (:intent, CURRENT_TIMESTAMP, :status, false);
12 changes: 12 additions & 0 deletions DSL/Resql/training/POST/update-intent-name.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Update intent name by inserting a new record with the new name and copying over status and isForService from the old record.
-- Expects :oldIntent and :newIntent parameters.
INSERT INTO intent (intent, status, isForService, created)
SELECT
:newIntent,
status,
isForService,
CURRENT_TIMESTAMP
FROM intent
WHERE intent = :oldIntent
ORDER BY created DESC
LIMIT 1;
10 changes: 8 additions & 2 deletions DSL/Resql/training/POST/update-intent.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ INSERT INTO intent (intent, created, status, isForService)
SELECT
:intent,
CURRENT_TIMESTAMP,
COALESCE(:status, latest_intent.status),
COALESCE(:isForService, latest_intent.isForService)
COALESCE(NULLIF(:status, ''), latest_intent.status),
COALESCE(
CASE
WHEN CAST(:isForService AS TEXT) = '' THEN NULL
ELSE CAST(:isForService AS BOOLEAN)
END,
latest_intent.isForService
)
FROM (
-- Find the latest version of the specific intent
SELECT DISTINCT ON (intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ updateInDatabase:
body:
intent: ${intent}
isForService: ${isForService}
status: ""
result: addIntentResult

returnSuccess:
Expand Down
5 changes: 3 additions & 2 deletions DSL/Ruuter.private/training/POST/rasa/intents/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,10 @@ addNewIntentInPipeline:
addInDatabase:
call: http.post
args:
url: "[#TRAINING_RESQL]/add-intent"
url: "[#TRAINING_RESQL]/update-intent-name"
body:
intent: ${incoming.body.newName}
oldIntent: ${incoming.body.oldName}
newIntent: ${incoming.body.newName}
result: addInDatabaseResult

deleteOldIntentFile:
Expand Down
1 change: 1 addition & 0 deletions DSL/Ruuter.private/training/POST/rasa/responses/add.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ updateIntentStatus:
url: "[#TRAINING_RESQL]/update-intent"
body:
intent: ${intent}
isForService: ""
status: "NOT_TRAINED"
result: updateIntentStatusResult
next: returnSuccess
Expand Down
1 change: 1 addition & 0 deletions DSL/Ruuter.private/training/POST/rasa/responses/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ updateIntentStatus:
url: "[#TRAINING_RESQL]/update-intent"
body:
intent: ${intent}
isForService: ""
status: "NOT_TRAINED"
result: updateIntentStatusResult
next: returnSuccess
Expand Down
Loading