Add support to switch between deno and nodejs function executor
This commit is contained in:
@@ -152,10 +152,10 @@ timer = Blueprint('timer', __name__)
|
||||
@login_required
|
||||
def overview():
|
||||
timer_functions = db.execute("""
|
||||
SELECT id, name, code, environment, trigger_type,
|
||||
frequency_minutes, run_date, next_run,
|
||||
last_run, enabled, invocation_count
|
||||
FROM timer_functions
|
||||
SELECT id, name, code, environment, trigger_type,
|
||||
frequency_minutes, run_date, next_run,
|
||||
last_run, enabled, invocation_count, runtime
|
||||
FROM timer_functions
|
||||
WHERE user_id = %s
|
||||
ORDER BY id DESC
|
||||
""", [current_user.id])
|
||||
@@ -182,6 +182,7 @@ def new():
|
||||
try:
|
||||
data = request.json
|
||||
trigger_type = data.get('trigger_type')
|
||||
runtime = data.get('runtime', 'node')
|
||||
|
||||
# Validate trigger type
|
||||
if trigger_type not in ('interval', 'date'):
|
||||
@@ -202,9 +203,9 @@ def new():
|
||||
# Insert new timer function
|
||||
db.execute("""
|
||||
INSERT INTO timer_functions
|
||||
(name, code, environment, user_id, trigger_type,
|
||||
frequency_minutes, run_date, next_run, enabled)
|
||||
VALUES (%s, %s, %s::jsonb, %s, %s, %s, %s, %s, %s)
|
||||
(name, code, environment, user_id, trigger_type,
|
||||
frequency_minutes, run_date, next_run, enabled, runtime)
|
||||
VALUES (%s, %s, %s::jsonb, %s, %s, %s, %s, %s, %s, %s)
|
||||
RETURNING id
|
||||
""", [
|
||||
data.get('name'),
|
||||
@@ -215,7 +216,8 @@ def new():
|
||||
frequency_minutes if trigger_type == 'interval' else None,
|
||||
run_date if trigger_type == 'date' else None,
|
||||
next_run,
|
||||
True
|
||||
True,
|
||||
runtime
|
||||
],
|
||||
commit=True)
|
||||
|
||||
@@ -236,10 +238,10 @@ def edit(function_id):
|
||||
if request.method == 'GET':
|
||||
# Fetch the timer function
|
||||
timer_function = db.execute("""
|
||||
SELECT id, name, code, environment, version_number, trigger_type,
|
||||
frequency_minutes, run_date, next_run,
|
||||
last_run, enabled, invocation_count
|
||||
FROM timer_functions
|
||||
SELECT id, name, code, environment, version_number, trigger_type,
|
||||
frequency_minutes, run_date, next_run,
|
||||
last_run, enabled, invocation_count, runtime
|
||||
FROM timer_functions
|
||||
WHERE id = %s AND user_id = %s
|
||||
""", [function_id, current_user.id], one=True)
|
||||
|
||||
@@ -254,7 +256,8 @@ def edit(function_id):
|
||||
|
||||
args = {
|
||||
'function_id': function_id,
|
||||
'timer_function': timer_function
|
||||
'timer_function': timer_function,
|
||||
'runtime': timer_function.get('runtime', 'node')
|
||||
}
|
||||
|
||||
if htmx:
|
||||
@@ -265,6 +268,7 @@ def edit(function_id):
|
||||
try:
|
||||
data = request.json
|
||||
trigger_type = data.get('trigger_type')
|
||||
runtime = data.get('runtime', 'node')
|
||||
|
||||
# Validate trigger type
|
||||
if trigger_type not in ('interval', 'date'):
|
||||
@@ -292,7 +296,8 @@ def edit(function_id):
|
||||
frequency_minutes = %s,
|
||||
run_date = %s,
|
||||
next_run = %s,
|
||||
enabled = %s
|
||||
enabled = %s,
|
||||
runtime = %s
|
||||
WHERE id = %s AND user_id = %s
|
||||
RETURNING id
|
||||
""", [
|
||||
@@ -304,6 +309,7 @@ def edit(function_id):
|
||||
run_date if trigger_type == 'date' else None,
|
||||
next_run,
|
||||
data.get('is_enabled', True), # Default to True if not provided
|
||||
runtime,
|
||||
function_id,
|
||||
current_user.id
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user