git-svn-id: svn://192.168.0.12/source@347 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -211,7 +211,7 @@ bool SInfluencer::makeTable(SDatagroup &_datagroup)
|
||||
m_pSInitializer->insertLog("Make influencer influencer");
|
||||
m_STInfluencer.makeTable(_datagroup, m_mapCategory);
|
||||
m_pSInitializer->insertLog("Make influencer stats_json");
|
||||
//m_SStatsJson.makeTable(_datagroup, m_mapCategory);
|
||||
// m_SStatsJson.makeTable(_datagroup, m_mapCategory);
|
||||
m_SStatsJson.makeTable(_datagroup, m_STInfluencer);
|
||||
}
|
||||
return true;
|
||||
@@ -247,17 +247,23 @@ bool SInfluencer::STInfluencer::SaveDataFile(int _companyNum)
|
||||
stream.setAutoDetectUnicode(true);
|
||||
stream << "Category," << "ID," << "Nick," << "Title," << "Url," << "Like," << "Share," << "Body," << "Reply," << "Value" << "\n";
|
||||
|
||||
QMapIterator<int, QList<stInfluencer>> iter1(m_mapInfluencerOfCategory);
|
||||
while (iter1.hasNext())
|
||||
QMapIterator<int, QMap<int, QList<stInfluencer>>> iter(m_mapInfluencerOfGroup);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter1.next();
|
||||
int nCategoryNum = iter1.key();
|
||||
const QList<stInfluencer> listInfluencer = iter1.value();
|
||||
foreach (stInfluencer Influecner, listInfluencer)
|
||||
iter.next();
|
||||
|
||||
QMapIterator<int, QList<stInfluencer>> iter2(iter.value());
|
||||
while (iter2.hasNext())
|
||||
{
|
||||
stream << Influecner.category_num << "," << Influecner.id_id << "," << Influecner.nickname_nickname << "," << Influecner.community_title << ","
|
||||
<< "http://" + Influecner.community_url << "," << Influecner.likecount << "," << Influecner.sharecount << "," << Influecner.bodycount << ","
|
||||
<< Influecner.replycount << "," << Influecner.influencervalue << "\n";
|
||||
iter2.next();
|
||||
|
||||
const QList<stInfluencer> listInfluencer = iter2.value();
|
||||
foreach (stInfluencer Influecner, listInfluencer)
|
||||
{
|
||||
stream << Influecner.category_num << "," << Influecner.id_id << "," << Influecner.nickname_nickname << "," << Influecner.community_title << ","
|
||||
<< "http://" + Influecner.community_url << "," << Influecner.likecount << "," << Influecner.sharecount << "," << Influecner.bodycount << ","
|
||||
<< Influecner.replycount << "," << Influecner.influencervalue << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,10 +279,12 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
const QStringList* orderedUrl = _datagroup.getOrderedUrl();
|
||||
|
||||
const int* anColumn = m_pSInitializer->getColumnIntArray();
|
||||
m_mapInfluencerGroupInfo = m_pSInitializer->getInfluencerGroup();
|
||||
|
||||
for (QMap<int, stReal>::const_iterator iterPos = _mapCategory.constBegin(); iterPos != _mapCategory.constEnd(); iterPos++)
|
||||
{
|
||||
QMap<SDatagroup::stProfileurlKey, stInfluencer> mapRank;
|
||||
int nCategoryNum = iterPos.key();
|
||||
const stReal& streal = iterPos.value();
|
||||
foreach (const QString& _url, *orderedUrl)
|
||||
{
|
||||
@@ -293,7 +301,7 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
mapRank[stprofileurlkey].community_num = _datagroup.getstBody(_url)->community_num;
|
||||
mapRank[stprofileurlkey].profile = (*(_datagroup.getmapBody(stprofileurlkey)))[anColumn[SInitializer::E_DATA_article_profile]].trimmed();
|
||||
mapRank[stprofileurlkey].profileurl = (*(_datagroup.getmapBody(stprofileurlkey)))[anColumn[SInitializer::E_DATA_article_profileurl]].trimmed();
|
||||
mapRank[stprofileurlkey].category_num = iterPos.key();
|
||||
mapRank[stprofileurlkey].category_num = nCategoryNum;
|
||||
//mapRank[stprofileurlkey].community_title = _datagroup.getstCommunity(*(_datagroup.getmapBody(stprofileurlkey)))->title;
|
||||
//mapRank[stprofileurlkey].community_url = _datagroup.getstCommunity(*(_datagroup.getmapBody(stprofileurlkey)))->url;
|
||||
//mapRank[stprofileurlkey].community_id = _datagroup.getstCommunity(*(_datagroup.getmapBody(stprofileurlkey)))->id;
|
||||
@@ -321,7 +329,6 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//insert Reply
|
||||
const QMap<int, SDatagroup::stReply>* mapstReply = _datagroup.getstReply(_url);
|
||||
if (mapstReply == 0) continue;
|
||||
@@ -339,7 +346,6 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (QMap<SDatagroup::stProfileurlKey, stInfluencer>::iterator iterPos1 = mapRank.begin(); iterPos1 != mapRank.end(); iterPos1++)
|
||||
{
|
||||
stInfluencer &val = iterPos1.value();
|
||||
@@ -347,174 +353,18 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
val.interactionrank = idrankbyinteractionColumn.makeIdrankbyinteractionColumnJson(val);
|
||||
}
|
||||
|
||||
|
||||
// for (QMap<SDatagroup::stProfileurlKey, stInfluencer>::iterator iterPos1 = mapRank.begin(); iterPos1 != mapRank.end(); iterPos1++)
|
||||
// {
|
||||
// stInfluencer &val = iterPos1.value();
|
||||
// //val.influencervalue = val.bodycount * m_pSInitializer->getInfluencerParam(0) + val.replycount * m_pSInitializer->getInfluencerParam(1);
|
||||
// if (val.bodycount == 0)
|
||||
// val.influencervalue = 0;
|
||||
// else
|
||||
// val.influencervalue = static_cast<double>(val.replycount + val.sharecount + val.likecount) * m_pSInitializer->getInfluencerParam().A /
|
||||
// (val.bodycount * m_pSInitializer->getInfluencerParam().B);
|
||||
// }
|
||||
|
||||
SInfluencerWeight influecnerWeight;
|
||||
for (QMap<SDatagroup::stProfileurlKey, stInfluencer>::iterator iter = mapRank.begin(); iter != mapRank.end(); iter++)
|
||||
{
|
||||
stInfluencer &influencer = iter.value();
|
||||
influecnerWeight.insert(influencer);
|
||||
}
|
||||
|
||||
influecnerWeight.calculateWeight();
|
||||
|
||||
for (QMap<SDatagroup::stProfileurlKey, stInfluencer>::iterator iter = mapRank.begin(); iter != mapRank.end(); iter++)
|
||||
{
|
||||
stInfluencer &influencer = iter.value();
|
||||
influencer.influencervalue = influecnerWeight.getInfluenceValue(influencer);
|
||||
}
|
||||
|
||||
|
||||
QList<stInfluencer> listmap = mapRank.values();
|
||||
qSort(listmap.begin(), listmap.end(), isGreaterInfluencerValue());
|
||||
int rank = 1;
|
||||
for (QList<stInfluencer>::iterator iterPos1 = listmap.begin(); iterPos1 != listmap.end(); iterPos1++)
|
||||
{
|
||||
iterPos1->rank = rank++;
|
||||
}
|
||||
m_listMap.append(listmap);
|
||||
int nInfluencerGroupNum = getInfluencerGroupNum(nCategoryNum);
|
||||
m_mapInfluencerOfGroup[nInfluencerGroupNum][nCategoryNum].append(mapRank.values());
|
||||
}
|
||||
|
||||
setInfluencerValueWieght();
|
||||
processDuplicatedInfluencer();
|
||||
|
||||
setInfluecnerRank();
|
||||
|
||||
//Make Map Influencer Group by Category within limit range, Sort by rank
|
||||
int nInfluencerLimitFrom = m_pSInitializer->getInfluencerLimitFrom().toInt();
|
||||
int nInfluencerLimitTo = m_pSInitializer->getInfluencerLimitTo().toInt();
|
||||
QListIterator<stInfluencer> iter(m_listMap);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
const stInfluencer& influencer = iter.next();
|
||||
if (influencer.rank < nInfluencerLimitFrom || nInfluencerLimitTo < influencer.rank)
|
||||
continue;
|
||||
|
||||
m_mapInfluencerOfCategory[influencer.category_num].append(influencer);
|
||||
}
|
||||
|
||||
for (QMap<int, QList<stInfluencer>>::iterator iter = m_mapInfluencerOfCategory.begin(); iter != m_mapInfluencerOfCategory.end(); iter++)
|
||||
{
|
||||
QList<stInfluencer>& listInfluencer = iter.value();
|
||||
qSort(listInfluencer.begin(), listInfluencer.end(), isGreaterInfluencerRank());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
copyInfluencerFromGroupToList();
|
||||
}
|
||||
|
||||
/*
|
||||
bool SInfluencer::STInfluencer::uploadData(QSqlDatabase &_db, const int &_nCompany)
|
||||
{
|
||||
QString strQuery = "delete from influencer where company_num = " + QString::number(_nCompany);
|
||||
QSqlQuery query(_db);
|
||||
if (query.exec(strQuery.toUtf8()) == false)
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
strQuery = "insert into influencer (rank,company_num,id_num,nickname_num,community_num,bodycount,replycount,influencervalue,profile,profileurl,id_id)"
|
||||
" VALUES (:RANK,:COMPANY_NUM,:ID_NUM,:NICKNAME_NUM,:COMMUNITY_NUM,:BODY_COUNT,:REPLY_COUNT,:INPL,:PROFILE,:PROFILE_URL,:ID_ID)";
|
||||
|
||||
query.clear();
|
||||
query.prepare(strQuery.toUtf8());
|
||||
|
||||
foreach (const stInfluencer& stinfluencer, m_listMap)
|
||||
{
|
||||
query.bindValue(":RANK", stinfluencer.rank);
|
||||
query.bindValue(":COMPANY_NUM", _nCompany);
|
||||
query.bindValue(":ID_NUM", stinfluencer.id_num);
|
||||
query.bindValue(":NICKNAME_NUM", stinfluencer.nickname_num);
|
||||
query.bindValue(":COMMUNITY_NUM", stinfluencer.community_num);
|
||||
query.bindValue(":BODY_COUNT", stinfluencer.bodycount);
|
||||
query.bindValue(":REPLY_COUNT", stinfluencer.replycount);
|
||||
query.bindValue(":ID_ID", stinfluencer.id_id);
|
||||
query.bindValue(":INPL", QString::number(stinfluencer.influencervalue, 'g', 3));
|
||||
//query.bindValue(":PROFILE", ((stinfluencer.profile.trimmed().isEmpty())? " " : sqlString(stinfluencer.profile).trimmed().replace(QChar(160), "")));
|
||||
//query.bindValue(":PROFILE_URL", ((stinfluencer.profileurl.trimmed().isEmpty())? " ", stinfluencer.profileurl.trimmed()));
|
||||
query.bindValue(":PROFILE", sqlString(stinfluencer.profile).trimmed().replace(QChar(160), ""));
|
||||
query.bindValue(":PROFILE_URL", stinfluencer.profileurl.trimmed());
|
||||
if (query.exec() == false)
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
strQuery = "update dbinfo set influencercount = " + QString::number(m_listMap.size()) + " where company_num = "
|
||||
+ QString::number(_nCompany);
|
||||
query.exec(strQuery);
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
//bool SInfluencer::STInfluencer::uploadData(QSqlDatabase &_db, const int &_nCompany)
|
||||
//{
|
||||
// QString strQuery = "delete from influencer_" + QString::number(_nCompany) + "_update";
|
||||
// QSqlQuery query(_db);
|
||||
// if (query.exec(strQuery.toUtf8()) == false)
|
||||
// {
|
||||
// m_pSInitializer->insertLog(query.lastQuery());
|
||||
// m_pSInitializer->insertLog(query.lastError().text());
|
||||
// return false;
|
||||
// }
|
||||
// strQuery = "insert into influencer_" + QString::number(_nCompany) +
|
||||
// "_update (rank,category_num,id_num,nickname_num,community_num,bodycount,replycount, likecount, sharecount, influencervalue,profile,profileurl,id_id,"
|
||||
// "community_title,community_url,community_id,nickname_nickname,nickname_exnickname,platformname_num,idrankbyinteraction,platformname_name) VALUES (";
|
||||
|
||||
// query.clear();
|
||||
|
||||
// foreach (const stInfluencer& stinfluencer, m_listMap)
|
||||
// {
|
||||
// QString str = strQuery;
|
||||
// str += QString::number(stinfluencer.rank) + ",";
|
||||
// str += QString::number(stinfluencer.category_num) + ",";
|
||||
// str += QString::number(stinfluencer.id_num) + ",";
|
||||
// str += QString::number(stinfluencer.nickname_num) + ",";
|
||||
// str += QString::number(stinfluencer.community_num) + ",";
|
||||
// str += QString::number(stinfluencer.bodycount) + ",";
|
||||
// str += QString::number(stinfluencer.replycount) + ",";
|
||||
// str += QString::number(stinfluencer.likecount) + ",";
|
||||
// str += QString::number(stinfluencer.sharecount) + ",";
|
||||
// str += QString::number(stinfluencer.influencervalue, 'g', 3) + ",";
|
||||
// str += "'" + sqlString(stinfluencer.profile).trimmed().replace(QChar(160), "") + "',";
|
||||
// str += "'" + sqlString(stinfluencer.profileurl.trimmed()) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.id_id) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.community_title) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.community_url) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.community_id) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.nickname_nickname) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.nickname_exnickname) + "',";
|
||||
// str += QString::number(stinfluencer.platformname_num) + ",";
|
||||
//str += "'" + sqlString(stinfluencer.interactionrank) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.platformname_name) + "')";
|
||||
|
||||
// if (query.exec(str.toUtf8()) == false)
|
||||
// {
|
||||
// m_pSInitializer->insertLog(query.lastQuery());
|
||||
// m_pSInitializer->insertLog(query.lastError().text());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// strQuery = "update dbinfo set influencercount = " + QString::number(m_listMap.size()) + " where company_num = "
|
||||
// + QString::number(_nCompany);
|
||||
// query.exec(strQuery);
|
||||
|
||||
// return true;
|
||||
//}
|
||||
|
||||
bool SInfluencer::STInfluencer::uploadData(QSqlDatabase &_db, const int &_nCompany)
|
||||
{
|
||||
QString strQuery = "delete from influencer_" + QString::number(_nCompany) + "_update";
|
||||
@@ -531,94 +381,39 @@ bool SInfluencer::STInfluencer::uploadData(QSqlDatabase &_db, const int &_nCompa
|
||||
|
||||
query.clear();
|
||||
|
||||
QMapIterator<int, QList<stInfluencer>> iter1(m_mapInfluencerOfCategory);
|
||||
while (iter1.hasNext())
|
||||
foreach (const stInfluencer& stinfluencer, m_listMap)
|
||||
{
|
||||
iter1.next();
|
||||
const QList<stInfluencer>& listInfluencer = iter1.value();
|
||||
foreach (stInfluencer stinfluencer, listInfluencer)
|
||||
QString str = strQuery;
|
||||
str += QString::number(stinfluencer.rank) + ",";
|
||||
str += QString::number(stinfluencer.category_num) + ",";
|
||||
str += QString::number(stinfluencer.id_num) + ",";
|
||||
str += QString::number(stinfluencer.nickname_num) + ",";
|
||||
str += QString::number(stinfluencer.community_num) + ",";
|
||||
str += QString::number(stinfluencer.bodycount) + ",";
|
||||
str += QString::number(stinfluencer.replycount) + ",";
|
||||
str += QString::number(stinfluencer.likecount) + ",";
|
||||
str += QString::number(stinfluencer.sharecount) + ",";
|
||||
str += QString::number(stinfluencer.influencervalue, 'g', 3) + ",";
|
||||
str += "'" + sqlString(stinfluencer.profile).trimmed().replace(QChar(160), "") + "',";
|
||||
str += "'" + sqlString(stinfluencer.profileurl.trimmed()) + "',";
|
||||
str += "'" + sqlString(stinfluencer.id_id) + "',";
|
||||
str += "'" + sqlString(stinfluencer.community_title) + "',";
|
||||
str += "'" + sqlString(stinfluencer.community_url) + "',";
|
||||
str += "'" + sqlString(stinfluencer.community_id) + "',";
|
||||
str += "'" + sqlString(stinfluencer.nickname_nickname) + "',";
|
||||
str += "'" + sqlString(stinfluencer.nickname_exnickname) + "',";
|
||||
str += QString::number(stinfluencer.platformname_num) + ",";
|
||||
str += "'" + sqlString(stinfluencer.interactionrank) + "',";
|
||||
str += "'" + sqlString(stinfluencer.platformname_name) + "')";
|
||||
|
||||
if (query.exec(str.toUtf8()) == false)
|
||||
{
|
||||
QString str = strQuery;
|
||||
str += QString::number(stinfluencer.rank) + ",";
|
||||
str += QString::number(stinfluencer.category_num) + ",";
|
||||
str += QString::number(stinfluencer.id_num) + ",";
|
||||
str += QString::number(stinfluencer.nickname_num) + ",";
|
||||
str += QString::number(stinfluencer.community_num) + ",";
|
||||
str += QString::number(stinfluencer.bodycount) + ",";
|
||||
str += QString::number(stinfluencer.replycount) + ",";
|
||||
str += QString::number(stinfluencer.likecount) + ",";
|
||||
str += QString::number(stinfluencer.sharecount) + ",";
|
||||
str += QString::number(stinfluencer.influencervalue, 'g', 3) + ",";
|
||||
str += "'" + sqlString(stinfluencer.profile).trimmed().replace(QChar(160), "") + "',";
|
||||
str += "'" + sqlString(stinfluencer.profileurl.trimmed()) + "',";
|
||||
str += "'" + sqlString(stinfluencer.id_id) + "',";
|
||||
str += "'" + sqlString(stinfluencer.community_title) + "',";
|
||||
str += "'" + sqlString(stinfluencer.community_url) + "',";
|
||||
str += "'" + sqlString(stinfluencer.community_id) + "',";
|
||||
str += "'" + sqlString(stinfluencer.nickname_nickname) + "',";
|
||||
str += "'" + sqlString(stinfluencer.nickname_exnickname) + "',";
|
||||
str += QString::number(stinfluencer.platformname_num) + ",";
|
||||
str += "'" + sqlString(stinfluencer.interactionrank) + "',";
|
||||
str += "'" + sqlString(stinfluencer.platformname_name) + "')";
|
||||
|
||||
if (query.exec(str.toUtf8()) == false)
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// foreach (const stInfluencer& stinfluencer, m_listMap)
|
||||
// {
|
||||
// QString str = strQuery;
|
||||
// str += QString::number(stinfluencer.rank) + ",";
|
||||
// str += QString::number(stinfluencer.category_num) + ",";
|
||||
// str += QString::number(stinfluencer.id_num) + ",";
|
||||
// str += QString::number(stinfluencer.nickname_num) + ",";
|
||||
// str += QString::number(stinfluencer.community_num) + ",";
|
||||
// str += QString::number(stinfluencer.bodycount) + ",";
|
||||
// str += QString::number(stinfluencer.replycount) + ",";
|
||||
// str += QString::number(stinfluencer.likecount) + ",";
|
||||
// str += QString::number(stinfluencer.sharecount) + ",";
|
||||
// str += QString::number(stinfluencer.influencervalue, 'g', 3) + ",";
|
||||
// str += "'" + sqlString(stinfluencer.profile).trimmed().replace(QChar(160), "") + "',";
|
||||
// str += "'" + sqlString(stinfluencer.profileurl.trimmed()) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.id_id) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.community_title) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.community_url) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.community_id) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.nickname_nickname) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.nickname_exnickname) + "',";
|
||||
// str += QString::number(stinfluencer.platformname_num) + ",";
|
||||
//str += "'" + sqlString(stinfluencer.interactionrank) + "',";
|
||||
// str += "'" + sqlString(stinfluencer.platformname_name) + "')";
|
||||
|
||||
// if (query.exec(str.toUtf8()) == false)
|
||||
// {
|
||||
// m_pSInitializer->insertLog(query.lastQuery());
|
||||
// m_pSInitializer->insertLog(query.lastError().text());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// strQuery = "delete from influencer_" + QString::number(_nCompany) + "_update " +
|
||||
// "where rank < " + m_pSInitializer->getInfluencerLimitFrom() + " or rank > " + m_pSInitializer->getInfluencerLimitTo();
|
||||
// if (query.exec(strQuery.toUtf8()) == false)
|
||||
// {
|
||||
// m_pSInitializer->insertLog(query.lastQuery());
|
||||
// m_pSInitializer->insertLog(query.lastError().text());
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
strQuery = "select count(*) from influencer_" + QString::number(_nCompany) + "_update";
|
||||
if (query.exec(strQuery.toUtf8()) == false)
|
||||
{
|
||||
@@ -657,6 +452,209 @@ m_pSInitializer->insertLog("influencer_" + QString::number(_nCompany) + " rename
|
||||
return true;
|
||||
}
|
||||
|
||||
int SInfluencer::STInfluencer::getInfluencerGroupNum(int _nCategoryNum)
|
||||
{
|
||||
QMapIterator<int, QList<int>> iter(m_mapInfluencerGroupInfo);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
int nGroupNum = iter.key();
|
||||
QList<int> listCategoryInfo = iter.value();
|
||||
for (int i=0; i<listCategoryInfo.count(); i++)
|
||||
{
|
||||
int nCategoryNum = listCategoryInfo.at(i);
|
||||
if (nCategoryNum == _nCategoryNum)
|
||||
return nGroupNum;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::setInfluencerValueWieght()
|
||||
{
|
||||
QMutableMapIterator<int, QMap<int, QList<stInfluencer>>> iter(m_mapInfluencerOfGroup);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
SInfluencerWeight influencerWeight;
|
||||
QMutableMapIterator<int, QList<stInfluencer>> iter2(iter.value());
|
||||
while (iter2.hasNext())
|
||||
{
|
||||
QList<stInfluencer> &listInfluencer = iter2.next().value();
|
||||
for (QList<stInfluencer>::iterator iter3 = listInfluencer.begin(); iter3 != listInfluencer.end(); iter3++)
|
||||
{
|
||||
influencerWeight.insert(*iter3);
|
||||
}
|
||||
|
||||
influencerWeight.calculateWeight();
|
||||
|
||||
for (QList<stInfluencer>::iterator iter3 = listInfluencer.begin(); iter3 != listInfluencer.end(); iter3++)
|
||||
{
|
||||
iter3->influencervalue = influencerWeight.getInfluenceValue(*iter3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::processDuplicatedInfluencer()
|
||||
{
|
||||
QMutableMapIterator<int, QMap<int, QList<stInfluencer>>> iter(m_mapInfluencerOfGroup);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QMap<QString, QList<double>> mapInfluencerValuesOfId = makeInfluencerValuesOfId(iter.value());
|
||||
QMap<QString, QList<double>> mapFilteredInfluencerValuesOfId = filterInfluencerValuesOfId(mapInfluencerValuesOfId);
|
||||
sortInfluencerValuesOfId(mapFilteredInfluencerValuesOfId);
|
||||
|
||||
setDuplicatedInfluencerFlag(iter.value(), mapFilteredInfluencerValuesOfId);
|
||||
}
|
||||
}
|
||||
|
||||
QMap<QString, QList<double>> SInfluencer::STInfluencer::makeInfluencerValuesOfId(QMap<int, QList<stInfluencer>> &_mapInfluencersOfCategory)
|
||||
{
|
||||
QMap<QString, QList<double>> mapInfluencerValuesOfId;
|
||||
|
||||
QMutableMapIterator<int, QList<stInfluencer>> iter(_mapInfluencersOfCategory);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QList<stInfluencer> &listInfluencer = iter.value();
|
||||
for (QList<stInfluencer>::iterator iter2 = listInfluencer.begin(); iter2 != listInfluencer.end(); iter2++)
|
||||
{
|
||||
mapInfluencerValuesOfId[iter2->id_id].append(iter2->influencervalue);
|
||||
}
|
||||
}
|
||||
|
||||
return mapInfluencerValuesOfId;
|
||||
}
|
||||
|
||||
QMap<QString, QList<double>> SInfluencer::STInfluencer::filterInfluencerValuesOfId(QMap<QString, QList<double>> &_mapInfluencerValuesOfId)
|
||||
{
|
||||
QMap<QString, QList<double>> mapFilteredInfluencerValuesOfId;
|
||||
|
||||
QMutableMapIterator<QString, QList<double>> iter(_mapInfluencerValuesOfId);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QString id = iter.key();
|
||||
QList<double> &listValue = iter.value();
|
||||
if (listValue.count() <= 1)
|
||||
continue;
|
||||
|
||||
mapFilteredInfluencerValuesOfId[id].append(listValue);
|
||||
}
|
||||
|
||||
return mapFilteredInfluencerValuesOfId;
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::sortInfluencerValuesOfId(QMap<QString, QList<double>> &_mapInfluencerValuesOfId)
|
||||
{
|
||||
QMutableMapIterator<QString, QList<double>> iter(_mapInfluencerValuesOfId);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QList<double> &listValue = iter.value();
|
||||
qSort(listValue.begin(), listValue.end(), qGreater<double>());
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::copyInfluencerFromGroupToList()
|
||||
{
|
||||
m_listMap.clear();
|
||||
|
||||
QMapIterator<int, QMap<int, QList<stInfluencer>>> iter(m_mapInfluencerOfGroup);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QMapIterator<int, QList<stInfluencer>> iter2(iter.value());
|
||||
while (iter2.hasNext())
|
||||
{
|
||||
iter2.next();
|
||||
|
||||
m_listMap.append(iter2.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::sortInfluencerByValue()
|
||||
{
|
||||
QMutableMapIterator<int, QMap<int, QList<stInfluencer>>> iter(m_mapInfluencerOfGroup);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QMutableMapIterator<int, QList<stInfluencer>> iter2(iter.value());
|
||||
while (iter2.hasNext())
|
||||
{
|
||||
iter2.next();
|
||||
|
||||
QList<stInfluencer> &listInfluencer = iter2.value();
|
||||
qSort(listInfluencer.begin(), listInfluencer.end(), isGreaterInfluencerValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::setInfluecnerRank()
|
||||
{
|
||||
sortInfluencerByValue();
|
||||
|
||||
QMutableMapIterator<int, QMap<int, QList<stInfluencer>>> iter(m_mapInfluencerOfGroup);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QMutableMapIterator<int, QList<stInfluencer>> iter2(iter.value());
|
||||
while (iter2.hasNext())
|
||||
{
|
||||
QList<stInfluencer> &listInfluencer = iter2.next().value();
|
||||
|
||||
int rank = 1;
|
||||
for (QList<stInfluencer>::iterator iter3 = listInfluencer.begin(); iter3 != listInfluencer.end(); iter3++)
|
||||
{
|
||||
iter3->rank = rank++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::setDuplicatedInfluencerFlag(QMap<int, QList<stInfluencer>> &_mapInfluencersOfCategory, QMap<QString, QList<double>> &_mapInfluencerValuesOfId)
|
||||
{
|
||||
QMutableMapIterator<int, QList<stInfluencer>> iter(_mapInfluencersOfCategory);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
QList<stInfluencer> &listInfluencer = iter.value();
|
||||
for (QList<stInfluencer>::iterator iter2 = listInfluencer.begin(); iter2 != listInfluencer.end(); iter2++)
|
||||
{
|
||||
QString id = iter2->id_id;
|
||||
if (!_mapInfluencerValuesOfId.contains(id))
|
||||
continue;
|
||||
|
||||
double fValue = iter2->influencervalue;
|
||||
double fMaxValue = _mapInfluencerValuesOfId[id].first();
|
||||
|
||||
if (fMaxValue == fValue && fMaxValue >= 0)
|
||||
{
|
||||
iter2->isSelected = "true";
|
||||
_mapInfluencerValuesOfId[id][0] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
iter2->isSelected = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::SStatsInfBloggerRank::makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory)
|
||||
{
|
||||
const QMap<QString, QStringList>* mapBody = _datagroup.getmapBody();
|
||||
@@ -1348,135 +1346,6 @@ struct stDate
|
||||
stDate():dStart(2020, 1, 1), dEnd(1990, 1, 1){}
|
||||
};
|
||||
|
||||
|
||||
//void SInfluencer::SStatsJson::makeTable(SDatagroup &_datagroup, const QMap<int, stReal> &_mapCategory)
|
||||
//{
|
||||
// const QMap<QString, QStringList>* mapBody = _datagroup.getmapBody();
|
||||
// const QMap<QString, QMap<int, QStringList> >* mapReply = _datagroup.getmapReply();
|
||||
// const int* anColumn = m_pSInitializer->getColumnIntArray();
|
||||
// const QStringList *slOrderedUrl = _datagroup.getOrderedUrl();
|
||||
|
||||
// QMap<QString, stCount> mapCount;
|
||||
// QMap<QString, stDate> mapBodyDate;
|
||||
|
||||
// foreach (const QString& strUrl, *slOrderedUrl)
|
||||
// {
|
||||
// if (mapBody->contains(strUrl))
|
||||
// {
|
||||
// QString strKey = (*mapBody)[strUrl][anColumn[SInitializer::E_DATA_platform_name]].trimmed() + strSeparator + (*mapBody)[strUrl][anColumn[SInitializer::E_DATA_platform_form]].trimmed();
|
||||
// if (!mapCount.contains(strKey))
|
||||
// mapCount.insert(strKey, stCount());
|
||||
|
||||
// mapCount[strKey].body += 1;
|
||||
// mapCount[strKey].id.insert((*mapBody)[strUrl][anColumn[SInitializer::E_DATA_article_id]].trimmed());
|
||||
|
||||
// if (mapReply->contains(strUrl))
|
||||
// mapCount[strKey].reply += (*mapReply)[strUrl].size();
|
||||
|
||||
// if (!mapBodyDate.contains(strKey))
|
||||
// mapBodyDate.insert(strKey, stDate());
|
||||
// QDate dBodyDate = QDateTime::fromString((*mapBody)[strUrl][anColumn[SInitializer::E_DATA_article_date]].trimmed().replace("T", " "), "yyyy-MM-dd hh:mm:ss").date();
|
||||
// mapBodyDate[strKey].dStart = (mapBodyDate.value(strKey).dStart < dBodyDate) ? mapBodyDate.value(strKey).dStart : dBodyDate;
|
||||
// mapBodyDate[strKey].dEnd = (mapBodyDate.value(strKey).dEnd > dBodyDate) ? mapBodyDate.value(strKey).dEnd : dBodyDate;
|
||||
// }
|
||||
// }
|
||||
|
||||
// QSet<QString> setRealAllUrl;
|
||||
|
||||
// for (QMap<int, stReal>::const_iterator iterPos = _mapCategory.constBegin(); iterPos != _mapCategory.constEnd(); iterPos++)
|
||||
// {
|
||||
// stStatsJson ststatsjson;
|
||||
// ststatsjson.category_num = iterPos.key();
|
||||
// ststatsjson.platformname_num = 1;
|
||||
// ststatsjson.servicenum = 1;
|
||||
// ststatsjson.title = "info";
|
||||
// ststatsjson.subtitle = "";
|
||||
|
||||
// const stReal& streal = iterPos.value();
|
||||
// QSet<QString> setPlatformType;
|
||||
|
||||
// foreach (const QString& strUrl, streal.m_setRealAllUrl)
|
||||
// {
|
||||
// if (mapBody->contains(strUrl))
|
||||
// setPlatformType.insert((*mapBody)[strUrl][anColumn[SInitializer::E_DATA_platform_name]].trimmed() + strSeparator + (*mapBody)[strUrl][anColumn[SInitializer::E_DATA_platform_form]].trimmed());
|
||||
// setRealAllUrl.insert(strUrl);
|
||||
// }
|
||||
|
||||
// unsigned int nBody = 0;
|
||||
// unsigned int nUser = 0;
|
||||
// QJsonObject jsonObj;
|
||||
|
||||
// foreach (const QString& strKey, setPlatformType)
|
||||
// {
|
||||
// if (strKey == "naver!@#blog")
|
||||
// {
|
||||
// nBody += ((mapBodyDate.value(strKey).dStart.daysTo(mapBodyDate.value(strKey).dEnd) + 1) * 1000);
|
||||
// if (setPlatformType.size() == 1)
|
||||
// jsonObj["pagenum"] = m_pSInitializer->getBlogPageNum();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// nBody += mapCount[strKey].body;
|
||||
// }
|
||||
|
||||
// nUser += mapCount[strKey].id.size();
|
||||
// }
|
||||
|
||||
// unsigned int nTotalCount = nBody;
|
||||
// jsonObj["totalcount"] = static_cast<int>(nTotalCount);
|
||||
// jsonObj["totalusercount"] = static_cast<int>(nUser);
|
||||
// if (!jsonObj.contains("pagenum"))
|
||||
// jsonObj["pagenum"] = -1;
|
||||
// QJsonDocument jsonDoc(jsonObj);
|
||||
// ststatsjson.jdata = jsonDoc.toJson();
|
||||
// m_listMap.append(ststatsjson);
|
||||
// }
|
||||
|
||||
// {
|
||||
// stStatsJson ststatsjson;
|
||||
// ststatsjson.category_num = -1;
|
||||
// ststatsjson.platformname_num = 1;
|
||||
// ststatsjson.servicenum = 1;
|
||||
// ststatsjson.title = "info";
|
||||
// ststatsjson.subtitle = "";
|
||||
|
||||
// QSet<QString> setPlatformType;
|
||||
|
||||
// foreach (const QString& strUrl, setRealAllUrl)
|
||||
// {
|
||||
// if (mapBody->contains(strUrl))
|
||||
// setPlatformType.insert((*mapBody)[strUrl][anColumn[SInitializer::E_DATA_platform_name]].trimmed() + strSeparator + (*mapBody)[strUrl][anColumn[SInitializer::E_DATA_platform_form]].trimmed());
|
||||
// }
|
||||
|
||||
// unsigned int nBody = 0;
|
||||
// unsigned int nUser = 0;
|
||||
// QJsonObject jsonObj;
|
||||
|
||||
// foreach (const QString& strKey, setPlatformType)
|
||||
// {
|
||||
// if (strKey == "naver!@#blog")
|
||||
// {
|
||||
// nBody += ((mapBodyDate.value(strKey).dStart.daysTo(mapBodyDate.value(strKey).dEnd) + 1) * 1000);
|
||||
// if (setPlatformType.size() == 1)
|
||||
// jsonObj["pagenum"] = m_pSInitializer->getBlogPageNum();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// nBody += mapCount[strKey].body;
|
||||
// }
|
||||
// nUser += mapCount[strKey].id.size();
|
||||
// }
|
||||
// unsigned int nTotalCount = nBody;
|
||||
// jsonObj["totalcount"] = static_cast<int>(nTotalCount);
|
||||
// jsonObj["totalusercount"] = static_cast<int>(nUser);
|
||||
// if (!jsonObj.contains("pagenum"))
|
||||
// jsonObj["pagenum"] = -1;
|
||||
// QJsonDocument jsonDoc(jsonObj);
|
||||
// ststatsjson.jdata = jsonDoc.toJson();
|
||||
// m_listMap.append(ststatsjson);
|
||||
// }
|
||||
//}
|
||||
|
||||
void SInfluencer::SStatsJson::makeGroupStatsJson(SGroupStatistics _groupStatistics, SPlatformStatistics _platformStatistics)
|
||||
{
|
||||
QList<int> listGroup = m_pSInitializer->getInfluencerGroup().keys();
|
||||
|
||||
Reference in New Issue
Block a user