Display http function invoked count in list

This commit is contained in:
Peter Stockings
2023-12-18 15:36:44 +11:00
parent efda151cd5
commit 8ffdf4c28c
4 changed files with 10 additions and 5 deletions

2
app.py
View File

@@ -210,7 +210,7 @@ def execute_http_function(function):
response = requests.post(API_URL, json={'code': code, 'request': request_obj, 'environment': environment})
response_data = response.json()
db.update_http_function_environment_info(function, json.dumps(response_data['environment']))
db.update_http_function_environment_info_and_invoked_count(function, json.dumps(response_data['environment']))
# Map the Node.js response to Flask response
flask_response = map_isolator_response_to_flask_response(response_data)

4
db.py
View File

@@ -64,9 +64,9 @@ class DataBase():
self.execute(
'UPDATE http_functions SET script_content=%s, environment_info=%s WHERE NAME=%s', [script_content, environment_info, name], commit=True)
def update_http_function_environment_info(self, name, environment_info):
def update_http_function_environment_info_and_invoked_count(self, name, environment_info):
self.execute(
'UPDATE http_functions SET environment_info=%s WHERE NAME=%s', [environment_info, name], commit=True)
'UPDATE http_functions SET environment_info=%s, invoked_count = invoked_count + 1 WHERE NAME=%s', [environment_info, name], commit=True)
def delete_http_function(self, name):
self.execute(

View File

@@ -8,7 +8,7 @@ def create_http_function_view_model(http_function):
"name": name,
"script_content": http_function['script_content'],
"url": f"{base_url}{name}",
"invoke_count": http_function['invoked_count'],
"invoked_count": http_function['invoked_count'],
"environment_info": http_function['environment_info']
}

View File

@@ -23,7 +23,12 @@
{% for function in http_functions %}
<tr class="border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted" data-id="63">
<td class="p-4 align-middle [&amp;:has([role=checkbox])]:pr-0 font-medium cursor-pointer"
data-id="66">{{ function.name }}</td>
data-id="66">{{ function.name }}
<span
class="inline-flex items-center justify-center w-4 h-4 ms-2 text-xs font-semibold text-blue-800 bg-blue-200 rounded-full">
{{ function.invoked_count }}
</span>
</td>
<td class="p-4 align-middle [&amp;:has([role=checkbox])]:pr-0 hidden md:table-cell" data-id="67">
<a href="{{ function.url }}">{{ function.url }}</a>
<button