Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
2.6 kB
2
Indexable
Never
Server Side:
def get_existing_tests_status_summary(self):
        query = f"SELECT " \
                f"SUM(CASE WHEN {WORKFLOW_COLUMNS['status'][0]} = 'QUEUE' THEN 1 ELSE 0 END) AS queue_result, " \
                f"SUM(CASE WHEN {WORKFLOW_COLUMNS['status'][0]} = 'SCHEDULED' THEN 1 ELSE 0 END) AS scheduled_result, " \
                f"SUM(CASE WHEN {WORKFLOW_COLUMNS['status'][0]} = 'STARTING' THEN 1 ELSE 0 END) AS starting_result, " \
                f"SUM(CASE WHEN {WORKFLOW_COLUMNS['status'][0]} = 'IN_PROGRESS' THEN 1 ELSE 0 END) AS in_progress_result " \
                f"FROM {WORKFLOW_TABLE_NAME};"

        results = self.db.execute_dql_query(query)["results"][0]
    
        status_dict = {
            'queue': results[0],
            'scheduled': results[1],
            'starting': results[2],
            'in_progress': results[3]
        }

        return {'status_statistics': status_dict}

I am making calls like:
def get_status_statistics(self):
        status_statistics = self.__result_db_handler.get_existing_tests_status_summary()
        return status_statistics

and
status_summary = workflow_initiator.get_status_statistics()
return jsonify(
        {
            "test-id": start_workflow.perf_workflow_config.test_id,
            "message": __get_user_message(resource_message),
            "status_statistics": status_summary,
        }

On the client side
click.echo(
        f"Tests Queue Statistics:\nNumber of tests ahead in QUEUE:{resp.json()['status_statistics']['queue']} \nNumber of tests SCHEDULED:{resp.json()['status_statistics']['scheduled']} \nNumber of tests STARTING:{resp.json()['status_statistics']['starting']} \nNumber of tests IN_PROGRESS:{resp.json()['status_statistics']['in_progress']} \nURL to Grafana Dashboard: https://g-e479d6ef8a.grafana-workspace.us-west-2.amazonaws.com/d/GXuswQq4z/performance-test-results?orgId=1&from=now-5m&to=now&var-internal_workflow_id={resp.json()['test-id']}"
    )

Which gives me error
    f"Tests Queue Statistics:\nNumber of tests ahead in QUEUE:{resp.json()['status_statistics']['queue']} \nNumber of tests SCHEDULED:{resp.json()['status_statistics']['scheduled']} \nNumber of tests STARTING:{resp.json()['status_statistics']['starting']} \nNumber of tests IN_PROGRESS:{resp.json()['status_statistics']['in_progress']} \nURL to Grafana Dashboard: https://g-e479d6ef8a.grafana-workspace.us-west-2.amazonaws.com/d/GXuswQq4z/performance-test-results?orgId=1&from=now-5m&to=now&var-internal_workflow_id={resp.json()['test-id']}"
                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'queue'
Leave a Comment