<commit_before>#include "businessobjectlist.h"
#include "bitcoinunits.h"
#include "ui_businessobjectlist.h"
#include "secdialog.h"
#include "ui_secdialog.h"
#include "writeorphan.h"
#include "walletmodel.h"
#include "guiutil.h"
#include "rpcpog.h"
#include <QPainter>
#include <QTableWidget>
#include <QGridLayout>
#include <QUrl>
#include <QTimer>
#include <univalue.h>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()

bool bSlotsCreated = false;

QStringList BusinessObjectList::GetHeaders(std::string sFields)
{
	QStringList pHeaders;
	UniValue aBO;
	if (ObjectType != "pog_leaderboard")
	{
		aBO	= GetBusinessObjectByFieldValue("object", "object_name", ObjectType);
		sFields = "id," + aBO["fields"].getValStr();	
	}
	
	sHeaderFields = sFields;

	std::vector<std::string> vFields = Split(sFields.c_str(),",");
	for (int i = 0; i < (int)vFields.size(); i++)
	{
		std::string sFieldName = vFields[i];
		pHeaders << GUIUtil::TOQS(sFieldName);
	}
	return pHeaders;
}

BusinessObjectList::BusinessObjectList(const PlatformStyle *platformStyle, QWidget *parent) : ui(new Ui::BusinessObjectList)
{
    ui->setupUi(this);
}


BusinessObjectList::~BusinessObjectList()
{
    delete ui;
}

void BusinessObjectList::setModel(WalletModel *model)
{
    this->model = model;
}

void BusinessObjectList::RefreshPogLeaderboard()
{
	if (ObjectType == "pog_leaderboard") 
		UpdateObject("pog_leaderboard");
}

void BusinessObjectList::UpdateObject(std::string objType)
{
	ObjectType = objType;
	std::string sFields;
    QString pString;

	if (objType == "pog_leaderboard")
	{
		sFields = "id,nickname,address,height,amount,weight";
		pString = GUIUtil::TOQS(GetPOGBusinessObjectList(ObjectType, sFields));
		// Update once per minute
		QTimer::singleShot(60000, this, SLOT(RefreshPogLeaderboard()));
	}
	else
	{
		UniValue aBO = GetBusinessObjectByFieldValue("object", "object_name", ObjectType);
		sFields = aBO["fields"].getValStr();
		pString	= GUIUtil::TOQS(GetBusinessObjectList(ObjectType, sFields));
	}<commit_msg>Issue #74 don't update PoG leaderboard till blockchain is synced<commit_after>#include "businessobjectlist.h"
#include "bitcoinunits.h"
#include "ui_businessobjectlist.h"
#include "secdialog.h"
#include "masternode-sync.h"
#include "ui_secdialog.h"
#include "writeorphan.h"
#include "walletmodel.h"
#include "guiutil.h"
#include "rpcpog.h"
#include <QPainter>
#include <QTableWidget>
#include <QGridLayout>
#include <QUrl>
#include <QTimer>
#include <univalue.h>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()

bool bSlotsCreated = false;

QStringList BusinessObjectList::GetHeaders(std::string sFields)
{
	QStringList pHeaders;
	UniValue aBO;
	if (ObjectType != "pog_leaderboard")
	{
		aBO	= GetBusinessObjectByFieldValue("object", "object_name", ObjectType);
		sFields = "id," + aBO["fields"].getValStr();	
	}
	
	sHeaderFields = sFields;

	std::vector<std::string> vFields = Split(sFields.c_str(),",");
	for (int i = 0; i < (int)vFields.size(); i++)
	{
		std::string sFieldName = vFields[i];
		pHeaders << GUIUtil::TOQS(sFieldName);
	}
	return pHeaders;
}

BusinessObjectList::BusinessObjectList(const PlatformStyle *platformStyle, QWidget *parent) : ui(new Ui::BusinessObjectList)
{
    ui->setupUi(this);
}


BusinessObjectList::~BusinessObjectList()
{
    delete ui;
}

void BusinessObjectList::setModel(WalletModel *model)
{
    this->model = model;
}

void BusinessObjectList::RefreshPogLeaderboard()
{
	if (ObjectType == "pog_leaderboard") 
		UpdateObject("pog_leaderboard");
}

void BusinessObjectList::UpdateObject(std::string objType)
{
	ObjectType = objType;
	std::string sFields;
    QString pString;

    if (objType == "pog_leaderboard" && masternodeSync.IsBlockchainSynced() )
	{
		sFields = "id,nickname,address,height,amount,weight";
		pString = GUIUtil::TOQS(GetPOGBusinessObjectList(ObjectType, sFields));
		// Update once per minute
		QTimer::singleShot(60000, this, SLOT(RefreshPogLeaderboard()));
	}
	else
	{
		UniValue aBO = GetBusinessObjectByFieldValue("object", "object_name", ObjectType);
		sFields = aBO["fields"].getValStr();
		pString	= GUIUtil::TOQS(GetBusinessObjectList(ObjectType, sFields));
	}
{'fraction_non_alphanumeric': 0.14521926671459381, 'fraction_numerical': 0.0033549005511622335, 'mean_word_length': 6.466905187835421, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5370125', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1470, 'n_words': 272}