Add in version history for http functions
and also load .env in dev mode
This commit is contained in:
11
db.py
11
db.py
@@ -54,12 +54,12 @@ class DataBase():
|
||||
|
||||
def get_http_function(self, user_id, name):
|
||||
http_function = self.execute(
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public, log_request, log_response, version_number FROM http_functions WHERE user_id=%s AND NAME=%s', [user_id, name], one=True)
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public, log_request, log_response, version_number, created_at FROM http_functions WHERE user_id=%s AND NAME=%s', [user_id, name], one=True)
|
||||
return http_function
|
||||
|
||||
def get_http_function_by_id(self, user_id, http_function_id):
|
||||
http_function = self.execute(
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public, log_request, log_response, version_number FROM http_functions WHERE user_id=%s AND id=%s', [user_id, http_function_id], one=True)
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public, log_request, log_response, version_number, created_at FROM http_functions WHERE user_id=%s AND id=%s', [user_id, http_function_id], one=True)
|
||||
return http_function
|
||||
|
||||
def create_new_http_function(self, user_id, name, script_content, environment_info, is_public, log_request, log_response):
|
||||
@@ -110,4 +110,9 @@ ORDER BY invocation_time DESC""", [http_function_id])
|
||||
def create_new_user(self, username, password_hash):
|
||||
new_user = self.execute(
|
||||
'INSERT INTO users (username, password_hash) VALUES (%s, %s) RETURNING id, username, password_hash, created_at', [username, password_hash], commit=True, one=True)
|
||||
return new_user
|
||||
return new_user
|
||||
|
||||
def get_http_function_history(self, function_id):
|
||||
http_function_history = self.execute(
|
||||
'SELECT version_id, http_function_id, script_content, version_number, updated_at FROM http_functions_versions WHERE http_function_id=%s AND version_number > 1 ORDER BY version_number DESC', [function_id])
|
||||
return http_function_history
|
||||
Reference in New Issue
Block a user