Skip to content

Commit

Permalink
add post method
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhoune committed Dec 10, 2023
1 parent fdff974 commit 6833c2f
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions bot_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def get_success_model(botName):
return fetch_success_model(success_model_url, botName, current_app.default_bot_pw, service_id=service_id, group_id=group_id)


@bot_resource.route('/<botName>/statistics')
@bot_resource.route('/<botName>/statistics', methods=['GET', 'POST'])
def get_bot_statistics(botName):
"""
Fetches the statistics of the bot
Expand All @@ -253,11 +253,30 @@ def get_bot_statistics(botName):
"error": f"Could not fetch event log from {event_log_generator_url}, make sure the service is running and the bot name is correct"
}, 400
statistics = bot_statistics(event_log)
bot_manager_url = request.args.get('bot-manager-url', None)

if bot_manager_url is not None:
if request.method == 'GET' and 'bot-manager-url' in request.args:

bot_manager_url = request.args['bot-manager-url']
try:
bot_model_json = fetch_bot_model(botName, bot_manager_url)
if bot_model_json is None:
print(f"Could not fetch bot model from {bot_manager_url}")
return {
"error": f"Could not fetch bot model from {bot_manager_url}"
}, 500
except Exception as e:
print(e)
return {
"error": f"Could not fetch bot model from {bot_manager_url}, make sure the service is running and the bot name is correct"
}, 500
elif request.method == 'POST':
bot_model_json = request.get_json().get('bot-model', None)
if bot_model_json is None:
return {
"error": "bot-model parameter is missing"
}, 400
try:

bot_parser = get_parser(bot_model_json)
net, im, fm = bot_parser.to_petri_net()
conformance_results = conformance(event_log, net, im, fm)
Expand Down

0 comments on commit 6833c2f

Please sign in to comment.