<commit_before>//
// Created by sergo on 26.10.18.
//
#include <lxd_async_operation_task.h>
#include <iostream>
#include <QtCore/QThread>
#include <include/employ_ws_server.h>


LXDAsyncOperationTask::LXDAsyncOperationTask(void (*func)(std::string, std::string &, int &),
                                             std::string sName, std::string sCMD, ModelRequest *pRequest) {
	TAG = "LXDAsyncOperationTask";
	m_func = func;
	m_pRequestClient = pRequest->client();
	m_sName = std::move(sName);
	m_sCMD = std::move(sCMD);
	m_sM = pRequest->m();
}

LXDAsyncOperationTask::~LXDAsyncOperationTask() = default;

void LXDAsyncOperationTask::run() {
	nlohmann::json jsonResponse;
	jsonResponse["cmd"] = m_sCMD;
	jsonResponse["m"] = m_sM;
	std::string sError;
	int nErrorCode = 500;

	auto *pWsServer = findEmploy<EmployWsServer>();
	auto jsonPrepare = jsonResponse;
	jsonPrepare["status"] = "Operation began";
	pWsServer->sendToOne(m_pRequestClient, jsonPrepare);

	m_func(m_sName, sError, nErrorCode);

	if (sError.empty()) {
		jsonResponse["result"] = "DONE";
	} else {
		jsonResponse["result"] = "FAIL";
		jsonResponse["error"] = sError;
		jsonResponse["code"] = nErrorCode;
	}

	pWsServer->sendToOne(m_pRequestClient, jsonResponse);
}<commit_msg>Rename atribute of response lxd task<commit_after>//
// Created by sergo on 26.10.18.
//
#include <lxd_async_operation_task.h>
#include <iostream>
#include <QtCore/QThread>
#include <include/employ_ws_server.h>


LXDAsyncOperationTask::LXDAsyncOperationTask(void (*func)(std::string, std::string &, int &),
                                             std::string sName, std::string sCMD, ModelRequest *pRequest) {
	TAG = "LXDAsyncOperationTask";
	m_func = func;
	m_pRequestClient = pRequest->client();
	m_sName = std::move(sName);
	m_sCMD = std::move(sCMD);
	m_sM = pRequest->m();
}

LXDAsyncOperationTask::~LXDAsyncOperationTask() = default;

void LXDAsyncOperationTask::run() {
	nlohmann::json jsonResponse;
	jsonResponse["cmd"] = m_sCMD;
	jsonResponse["m"] = m_sM;
	std::string sError;
	int nErrorCode = 500;

	auto *pWsServer = findEmploy<EmployWsServer>();
	auto jsonPrepare = jsonResponse;
	jsonPrepare["result"] = "Operation began";
	pWsServer->sendToOne(m_pRequestClient, jsonPrepare);

	m_func(m_sName, sError, nErrorCode);

	if (sError.empty()) {
		jsonResponse["result"] = "DONE";
	} else {
		jsonResponse["result"] = "FAIL";
		jsonResponse["error"] = sError;
		jsonResponse["code"] = nErrorCode;
	}

	pWsServer->sendToOne(m_pRequestClient, jsonResponse);
}
{'fraction_non_alphanumeric': 0.15029821073558647, 'fraction_numerical': 0.007157057654075547, 'mean_word_length': 5.048076923076923, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6984383', 'n_tokens_mistral': 937, 'n_tokens_neox': 895, 'n_words': 161}