git-svn-id: svn://192.168.0.12/source@344 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -25,7 +25,9 @@ SOURCES += main.cpp \
|
||||
sspammer.cpp \
|
||||
spowercafe.cpp \
|
||||
shttpsender.cpp \
|
||||
sservice.cpp
|
||||
sservice.cpp \
|
||||
sInfluencerInteractorUrlMaker.cpp \
|
||||
sconsumerstatistics.cpp
|
||||
|
||||
HEADERS += \
|
||||
sdbmanager.h \
|
||||
@@ -40,4 +42,6 @@ HEADERS += \
|
||||
sconsumer.h \
|
||||
sspammer.h \
|
||||
spowercafe.h \
|
||||
shttpsender.h
|
||||
shttpsender.h \
|
||||
sInfluencerInteractorUrlMaker.h \
|
||||
sconsumerstatistics.h
|
||||
|
||||
1306
FilterProcess/FilterProcess.pro.user
Normal file
1306
FilterProcess/FilterProcess.pro.user
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
|
||||
cout << QString(__TIME__).toStdString() << endl;
|
||||
SFilterProcess filter;
|
||||
|
||||
if (argc != 3)
|
||||
if (argc != 4)
|
||||
{
|
||||
cout << "check argument " << endl;
|
||||
return -1;
|
||||
@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
a.processEvents();
|
||||
|
||||
if (!filter.init(argv[1], argv[2]))
|
||||
if (!filter.init(argv[1], argv[2], argv[3]))
|
||||
//if (!filter.init(QString::number(370), "Check"))
|
||||
{
|
||||
cout << "filter init error" << endl;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "sconsumer.h"
|
||||
#include "sconsumerstatistics.h"
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
@@ -28,18 +29,29 @@ bool SConsumer::uploadData(int _companyNum)
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!m_SStatsJson.uploadData(dbWeb, _companyNum))
|
||||
{
|
||||
m_pSInitializer->insertLog("Fail to upload stats_json");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_pSInitializer->insertLog("End Consumer upload");
|
||||
m_pSInitializer->updateWebDBInfoState(dbWeb, _companyNum, "Consumer (Finish)");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SConsumer::SaveDataFile(int _companyNum)
|
||||
{
|
||||
if (!m_SStatsJson.SaveDataFile(_companyNum))
|
||||
{
|
||||
m_pSInitializer->insertLog("consumer statistics file save fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SConsumer::makeCategory(SDatagroup &_datagroup, int _nCategory, const QList<SInitializer::stFilter> &_listFilter)
|
||||
{
|
||||
QVector<QStringList> vecData[SInitializer::E_ARTICLE_MAX];
|
||||
@@ -198,7 +210,8 @@ void SConsumer::SBodyConsumerMap::makeTable(SDatagroup &_datagroup, const QMap<i
|
||||
stbody.id_num = _datagroup.getstBody(strUrl)->id_num;
|
||||
stbody.community_num = _datagroup.getstBody(strUrl)->community_num;
|
||||
stbody.nickname_num = _datagroup.getstBody(strUrl)->nickname_num;
|
||||
|
||||
stbody.likecount = _datagroup.getstBody(strUrl)->like;
|
||||
stbody.sharecount = _datagroup.getstBody(strUrl)->share;
|
||||
if (streal.m_mapRealReplyUniqueUrl.contains(strUrl))
|
||||
{
|
||||
stbody.realin |= REAL_REPLY;
|
||||
@@ -227,7 +240,8 @@ void SConsumer::SBodyConsumerMap::makeTable(SDatagroup &_datagroup, const QMap<i
|
||||
stbody.id_num = _datagroup.getstBody(strUrl)->id_num;
|
||||
stbody.community_num = _datagroup.getstBody(strUrl)->community_num;
|
||||
stbody.nickname_num = _datagroup.getstBody(strUrl)->nickname_num;
|
||||
|
||||
stbody.likecount = _datagroup.getstBody(strUrl)->like;
|
||||
stbody.sharecount = _datagroup.getstBody(strUrl)->share;
|
||||
foreach (int order, streal.m_mapRealReplyUniqueUrl.values(strUrl))
|
||||
{
|
||||
_datagroup.addRealReplyCategory(strUrl, order, iterPos.key());
|
||||
@@ -246,12 +260,15 @@ bool SConsumer::SBodyConsumerMap::changeTable(QSqlDatabase &_db, const int &_nCo
|
||||
strQuery += "body_consumer_map_" + QString::number(_nCompany) + " TO " + "body_consumer_map_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "body_consumer_map_" + QString::number(_nCompany) + "_update" + " TO " + "body_consumer_map_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "body_consumer_map_" + QString::number(_nCompany) + "_temp" + " TO " + "body_consumer_map_" + QString::number(_nCompany) + "_update";
|
||||
|
||||
m_pSInitializer->insertLog("body_consumer_map_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("body_consumer_map_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
@@ -301,7 +318,7 @@ bool SConsumer::SBodyConsumerMap::uploadData(QSqlDatabase &_db, const int &_nCom
|
||||
}
|
||||
|
||||
strQuery = QString("insert into body_consumer_map_" + QString::number(_nCompany) +
|
||||
"_update (num,body_num,category_num,realin,platformname_num,platformform_num,date,replycount,view,id_num,community_num,nickname_num) VALUES (");
|
||||
"_update (num,body_num,category_num,realin,platformname_num,platformform_num,date,replycount,viewcount,likecount,sharecount,id_num,community_num,nickname_num) VALUES (");
|
||||
|
||||
query.clear();
|
||||
|
||||
@@ -317,6 +334,8 @@ bool SConsumer::SBodyConsumerMap::uploadData(QSqlDatabase &_db, const int &_nCom
|
||||
str += "'" + sqlString(stbody.date) + "',";
|
||||
str += QString::number(stbody.replycount) + ",";
|
||||
str += QString::number(stbody.view) + ",";
|
||||
str += QString::number(stbody.likecount) + ",";
|
||||
str += QString::number(stbody.sharecount) + ",";
|
||||
str += QString::number(stbody.id_num) + ",";
|
||||
str += QString::number(stbody.community_num) + ",";
|
||||
str += QString::number(stbody.nickname_num) + ")";
|
||||
@@ -358,6 +377,17 @@ void SConsumer::SReplyConsumerMap::makeTable(SDatagroup &_datagroup, const QMap<
|
||||
}
|
||||
}
|
||||
|
||||
QString SConsumer::SStatsJson::getStatsJsonBySubtitle(QString _subtitle)
|
||||
{
|
||||
foreach (stStatsJson statsJson, m_listMap)
|
||||
{
|
||||
if (statsJson.subtitle == _subtitle)
|
||||
return statsJson.jdata;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void SConsumer::SStatsJson::makeTable(SDatagroup &_datagroup, const QMap<int, stReal> &_mapCategory)
|
||||
{
|
||||
const QMap<QString, QStringList>* mapBody = _datagroup.getmapBody();
|
||||
@@ -632,6 +662,16 @@ void SConsumer::SStatsJson::makeTable(SDatagroup &_datagroup, const QMap<int, st
|
||||
*/
|
||||
}
|
||||
|
||||
bool SConsumer::SStatsJson::SaveDataFile(const int &_nCompany)
|
||||
{
|
||||
QString strBodyStatisticsJson = getStatsJsonBySubtitle("body");
|
||||
QString strReplyStatisticsJson = getStatsJsonBySubtitle("reply");
|
||||
QString strAllStatisticsJson = getStatsJsonBySubtitle("all");
|
||||
SCousumerStatistics cousumerStatistics(strBodyStatisticsJson, strReplyStatisticsJson, strAllStatisticsJson);
|
||||
|
||||
return cousumerStatistics.saveCousumerStatisticsToExcelFile(_nCompany);
|
||||
}
|
||||
|
||||
bool SConsumer::SStatsJson::uploadData(QSqlDatabase &_db, const int &_nCompany)
|
||||
{
|
||||
QSqlQuery query(_db);
|
||||
|
||||
@@ -24,10 +24,13 @@ public:
|
||||
QString date;
|
||||
int replycount;
|
||||
int view;
|
||||
int likecount;
|
||||
int sharecount;
|
||||
int id_num;
|
||||
int community_num;
|
||||
int nickname_num;
|
||||
stBodyConsumerMap():num(0), body_num(0), category_num(0), realin(0), platformname_num(0), platformform_num(0), replycount(0), view(0), id_num(0), community_num(0), nickname_num(0){}
|
||||
stBodyConsumerMap():num(0), body_num(0), category_num(0), realin(0), platformname_num(0), platformform_num(0),
|
||||
replycount(0), view(0), likecount(0), sharecount(0), id_num(0), community_num(0), nickname_num(0){}
|
||||
};
|
||||
struct stReplyConsumerMap
|
||||
{
|
||||
@@ -117,10 +120,15 @@ public:
|
||||
private:
|
||||
SInitializer *m_pSInitializer;
|
||||
QList<stStatsJson> m_listMap;
|
||||
|
||||
private:
|
||||
QString getStatsJsonBySubtitle(QString _subtitle);
|
||||
|
||||
public:
|
||||
void setInitiaizer(SInitializer &_SInitializer) { m_pSInitializer = &_SInitializer; }
|
||||
void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
||||
bool uploadData(QSqlDatabase& _db, const int &_nCompany);
|
||||
bool SaveDataFile(const int &_nCompany);
|
||||
void clear(){ m_listMap.clear(); }
|
||||
};
|
||||
|
||||
@@ -134,6 +142,7 @@ private:
|
||||
public:
|
||||
virtual void setInitiaizer(SInitializer &_initializer);
|
||||
virtual bool uploadData(int _companyNum);
|
||||
virtual bool SaveDataFile(int _companyNum);
|
||||
virtual bool changeTable(int _companyNum);
|
||||
virtual bool makeCategory(SDatagroup &_datagroup, int _nCategory, const QList<SInitializer::stFilter> &_listFilter);
|
||||
virtual bool makeOverallCategory(int _nCategory);
|
||||
|
||||
215
FilterProcess/sconsumerstatistics.cpp
Normal file
215
FilterProcess/sconsumerstatistics.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
#include "sconsumerstatistics.h"
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QDate>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
SCousumerStatistics::SCousumerStatistics(QString _strBodyJson, QString _strReplyJson, QString _strAllJson)
|
||||
{
|
||||
m_BodyJsonArray = convertStringToJsonArray(_strBodyJson);
|
||||
m_ReplyJsonArray = convertStringToJsonArray(_strReplyJson);
|
||||
m_AllJsonArray = convertStringToJsonArray(_strAllJson);
|
||||
|
||||
setBanCategoryName();
|
||||
makeConsumerStatistics();
|
||||
}
|
||||
|
||||
void SCousumerStatistics::setBanCategoryName()
|
||||
{
|
||||
m_listBanCategoryName.append("ALLCATEGORY");
|
||||
m_listBanCategoryName.append("ALL");
|
||||
}
|
||||
|
||||
QJsonArray SCousumerStatistics::convertStringToJsonArray(QString _strJson)
|
||||
{
|
||||
QJsonDocument jdoc = QJsonDocument::fromJson(_strJson.toUtf8());
|
||||
|
||||
return getDataArrayFromJsonDocument(jdoc);
|
||||
}
|
||||
|
||||
void SCousumerStatistics::makeConsumerStatistics()
|
||||
{
|
||||
makeBodyStatistics();
|
||||
makeReplyStatistics();
|
||||
makeAllStatistics();
|
||||
}
|
||||
|
||||
QString SCousumerStatistics::getCategoryNameFromJsonObject(QJsonObject _jsonObject)
|
||||
{
|
||||
return _jsonObject["name"].toString().toUtf8();
|
||||
}
|
||||
|
||||
QJsonArray SCousumerStatistics::getDataArrayFromJsonDocument(QJsonDocument _jsonDocument)
|
||||
{
|
||||
return _jsonDocument.object()["data"].toArray();
|
||||
}
|
||||
|
||||
QJsonArray SCousumerStatistics::getValueArrayFromJsonObject(QJsonObject _jsonObject)
|
||||
{
|
||||
return _jsonObject["value"].toArray();
|
||||
}
|
||||
|
||||
void SCousumerStatistics::makeBodyStatistics()
|
||||
{
|
||||
for (int i=0; i < m_BodyJsonArray.count(); i++)
|
||||
{
|
||||
QJsonObject categoryObject = m_BodyJsonArray.at(i).toObject();
|
||||
QString strCategoryName = getCategoryNameFromJsonObject(categoryObject);
|
||||
|
||||
if (isBanCategory(strCategoryName))
|
||||
continue;
|
||||
|
||||
stConsumerCategoryStatistics& consumerCategoryStatistics = getCategory(strCategoryName);
|
||||
QJsonArray valueArray = getValueArrayFromJsonObject(categoryObject);
|
||||
for (int j=0; j < valueArray.count(); j++)
|
||||
{
|
||||
QJsonObject valueObject = valueArray.at(j).toObject();
|
||||
|
||||
QString strDate = valueObject["date"].toString();
|
||||
QDate date = QDate::fromString(strDate, "yyyyMMdd");
|
||||
int nCount = valueObject["count"].toInt();
|
||||
|
||||
consumerCategoryStatistics.mapCountInfoOfDate[strDate].bodyCount = nCount;
|
||||
consumerCategoryStatistics.mapCountInfoOfDate[date.toString("yyyyMM")].bodyCount += nCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SCousumerStatistics::makeReplyStatistics()
|
||||
{
|
||||
for (int i=0; i < m_ReplyJsonArray.count(); i++)
|
||||
{
|
||||
QJsonObject categoryObject = m_ReplyJsonArray.at(i).toObject();
|
||||
QString strCategoryName = getCategoryNameFromJsonObject(categoryObject);
|
||||
|
||||
if (isBanCategory(strCategoryName))
|
||||
continue;
|
||||
|
||||
stConsumerCategoryStatistics& consumerCategoryStatistics = getCategory(strCategoryName);
|
||||
QJsonArray valueArray = getValueArrayFromJsonObject(categoryObject);
|
||||
for (int j=0; j < valueArray.count(); j++)
|
||||
{
|
||||
QJsonObject valueObject = valueArray.at(j).toObject();
|
||||
|
||||
QString strDate = valueObject["date"].toString();
|
||||
QDate date = QDate::fromString(strDate, "yyyyMMdd");
|
||||
int nCount = valueObject["count"].toInt();
|
||||
|
||||
consumerCategoryStatistics.mapCountInfoOfDate[strDate].replyCount = nCount;
|
||||
consumerCategoryStatistics.mapCountInfoOfDate[date.toString("yyyyMM")].replyCount += nCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SCousumerStatistics::makeAllStatistics()
|
||||
{
|
||||
for (QList<stConsumerCategoryStatistics>::iterator iter = m_listConsumerCategoryStatistics.begin(); iter != m_listConsumerCategoryStatistics.end(); iter++)
|
||||
{
|
||||
stConsumerCategoryStatistics& consumerCategoryStatistics = (*iter);
|
||||
sumBodyAndReplyCount(consumerCategoryStatistics);
|
||||
}
|
||||
}
|
||||
|
||||
void SCousumerStatistics::sumBodyAndReplyCount(stConsumerCategoryStatistics& _consumerCategoryStatistics)
|
||||
{
|
||||
for (QMap<QString, stCountInfo>::iterator iter = _consumerCategoryStatistics.mapCountInfoOfDate.begin(); iter != _consumerCategoryStatistics.mapCountInfoOfDate.end(); iter++)
|
||||
{
|
||||
iter->allCount = iter->bodyCount + iter->replyCount;
|
||||
}
|
||||
}
|
||||
|
||||
stConsumerCategoryStatistics& SCousumerStatistics::getCategory(QString _strCategoryName)
|
||||
{
|
||||
if (!hasCategory(_strCategoryName))
|
||||
m_listConsumerCategoryStatistics.append(createCategory(_strCategoryName));
|
||||
|
||||
for (QList<stConsumerCategoryStatistics>::iterator iter = m_listConsumerCategoryStatistics.begin(); iter != m_listConsumerCategoryStatistics.end(); iter++)
|
||||
{
|
||||
if (iter->categoryName == _strCategoryName)
|
||||
return *iter;
|
||||
}
|
||||
}
|
||||
|
||||
bool SCousumerStatistics::hasCategory(QString _strCategoryName)
|
||||
{
|
||||
foreach (stConsumerCategoryStatistics consumerCategoryStatistics, m_listConsumerCategoryStatistics)
|
||||
{
|
||||
if (consumerCategoryStatistics.categoryName == _strCategoryName)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
stConsumerCategoryStatistics SCousumerStatistics::createCategory(QString _strCategoryName)
|
||||
{
|
||||
stConsumerCategoryStatistics consumerCategoryStatistics;
|
||||
consumerCategoryStatistics.categoryName = _strCategoryName;
|
||||
|
||||
return consumerCategoryStatistics;
|
||||
}
|
||||
|
||||
bool SCousumerStatistics::isLastDayOfMonth(QString _strDate)
|
||||
{
|
||||
QDate date = QDate::fromString(_strDate, "yyyyMMdd");
|
||||
if (date.day() == date.daysInMonth())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SCousumerStatistics::isBanCategory(QString _strCategoryName)
|
||||
{
|
||||
return m_listBanCategoryName.contains(_strCategoryName);
|
||||
}
|
||||
|
||||
void SCousumerStatistics::print()
|
||||
{
|
||||
foreach (stConsumerCategoryStatistics a, m_listConsumerCategoryStatistics)
|
||||
{
|
||||
QString category = a.categoryName;
|
||||
for(QMap<QString, stCountInfo>::const_iterator v = a.mapCountInfoOfDate.constBegin(); v!=a.mapCountInfoOfDate.constEnd(); v++)
|
||||
{
|
||||
QString date = v.key();
|
||||
int count = v.value().bodyCount;
|
||||
|
||||
//qDebug() << category << " : " << date << " : " << QString::number(count) << endl;
|
||||
qDebug() << QString::number(count) << QString::number(v.value().replyCount) << QString::number(v.value().allCount);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool SCousumerStatistics::saveCousumerStatisticsToExcelFile(int _nCompany)
|
||||
{
|
||||
QString strFileName = QString::number(_nCompany) + "_Consumer_" + QDate::currentDate().toString("yyyyMMdd") + ".csv";
|
||||
QFile statisticsFile(strFileName);
|
||||
if (!statisticsFile.open(QFile::WriteOnly | QFile::Truncate))
|
||||
{
|
||||
//process
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream stream(&statisticsFile);
|
||||
stream.setAutoDetectUnicode(true);
|
||||
stream << "Category Name" << "," << "All" << "," << "Body" << "," << "Reply" << "," << "Date" << "\n";
|
||||
|
||||
foreach (stConsumerCategoryStatistics consumerCategoryStatistics, m_listConsumerCategoryStatistics)
|
||||
{
|
||||
QString strCategoryName = consumerCategoryStatistics.categoryName;
|
||||
stream << strCategoryName.toUtf8();
|
||||
|
||||
QMapIterator<QString, stCountInfo> iter(consumerCategoryStatistics.mapCountInfoOfDate);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
stream << "," << iter.value().allCount << "," << iter.value().bodyCount << "," << iter.value().replyCount << "," << iter.key() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
statisticsFile.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
62
FilterProcess/sconsumerstatistics.h
Normal file
62
FilterProcess/sconsumerstatistics.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef SCOUSUMERSTATISTICS_H
|
||||
#define SCOUSUMERSTATISTICS_H
|
||||
|
||||
#include <QString>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
|
||||
struct stCountInfo
|
||||
{
|
||||
int allCount;
|
||||
int bodyCount;
|
||||
int replyCount;
|
||||
};
|
||||
|
||||
struct stConsumerCategoryStatistics
|
||||
{
|
||||
QString categoryName;
|
||||
QMap<QString, stCountInfo> mapCountInfoOfDate;
|
||||
};
|
||||
|
||||
class SCousumerStatistics
|
||||
{
|
||||
private:
|
||||
QJsonArray m_BodyJsonArray;
|
||||
QJsonArray m_ReplyJsonArray;
|
||||
QJsonArray m_AllJsonArray;
|
||||
|
||||
QList<QString> m_listBanCategoryName;
|
||||
|
||||
QList<stConsumerCategoryStatistics> m_listConsumerCategoryStatistics;
|
||||
|
||||
private:
|
||||
QJsonArray convertStringToJsonArray(QString _strJson);
|
||||
QString getCategoryNameFromJsonObject(QJsonObject _jsonObject);
|
||||
QJsonArray getDataArrayFromJsonDocument(QJsonDocument _jsonDocument);
|
||||
QJsonArray getValueArrayFromJsonObject(QJsonObject _jsonObject);
|
||||
|
||||
void setBanCategoryName();
|
||||
void makeConsumerStatistics();
|
||||
void makeBodyStatistics();
|
||||
void makeReplyStatistics();
|
||||
void makeAllStatistics();
|
||||
|
||||
bool hasCategory(QString _strCategoryName);
|
||||
bool isBanCategory(QString _strCategoryName);
|
||||
bool isLastDayOfMonth(QString _strDate);
|
||||
stConsumerCategoryStatistics& getCategory(QString _strCategoryName);
|
||||
stConsumerCategoryStatistics createCategory(QString _strCategoryName);
|
||||
void sumBodyAndReplyCount(stConsumerCategoryStatistics& _consumerCategoryStatistics);
|
||||
public:
|
||||
SCousumerStatistics(QString _strBodyJson, QString _strReplyJson, QString _strAllJson);
|
||||
void print();
|
||||
void print2();
|
||||
|
||||
bool saveCousumerStatisticsToExcelFile(int _nCompany);
|
||||
};
|
||||
|
||||
#endif // SCOUSUMERSTATISTICS_H
|
||||
@@ -568,6 +568,25 @@ const QMap<QString, QMap<int, QStringList> >* SDatagroup::getmapReply()
|
||||
return &m_mapReply;
|
||||
}
|
||||
|
||||
int SDatagroup::getBodyCount()
|
||||
{
|
||||
return m_SBody.getBodyCount();
|
||||
}
|
||||
|
||||
int SDatagroup::getUserCount()
|
||||
{
|
||||
return m_SBody.getUserCount();
|
||||
}
|
||||
|
||||
QMap<QString, int> SDatagroup::getMapBodyCountOfPlatform()
|
||||
{
|
||||
return m_SBody.getMapBodyCountOfPlatform();
|
||||
}
|
||||
|
||||
QMap<QString, int> SDatagroup::getMapUserCountOfPlatform()
|
||||
{
|
||||
return m_SBody.getMapUserCountOfPlatform();
|
||||
}
|
||||
|
||||
bool SDatagroup::SBody::putCategory(const QString &_url, const int &_nCategory)
|
||||
{
|
||||
@@ -677,7 +696,7 @@ bool SDatagroup::SBody::uploadData(QSqlDatabase &_db, const int& _nCompany, cons
|
||||
}
|
||||
|
||||
strQuery = "insert into body_" + QString::number(_nCompany) +
|
||||
"_update(num,id_num,nickname_num,community_num,id_id,platformname_num,platformform_num, title, data, url, view, date, replystartnum, replyendnum, replycount, `like`, share, lastupdate, realbycategorynum,"
|
||||
"_update(num,id_num,nickname_num,community_num,id_id,platformname_num,platformform_num, title, data, url, viewcount, date, replystartnum, replyendnum, replycount, likecount, sharecount, lastupdate, realbycategorynum,"
|
||||
"community_title, community_url, community_id, community_exid, platformname_name, platformform_form, nickname_nickname, nickname_exnickname) VALUES(";
|
||||
|
||||
foreach (const QString& url, _order)
|
||||
@@ -753,6 +772,85 @@ int SDatagroup::SBody::getBodyNum(const QString &_url)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int SDatagroup::SBody::getBodyCount()
|
||||
{
|
||||
int nBodyCount = 0;
|
||||
QSet<QString> setUrl;
|
||||
QMapIterator<QString, stBody> iter(m_mapBody);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
if (setUrl.contains(iter.value().url))
|
||||
continue;
|
||||
|
||||
setUrl.insert(iter.key());
|
||||
|
||||
nBodyCount++;
|
||||
}
|
||||
|
||||
return nBodyCount;
|
||||
}
|
||||
|
||||
int SDatagroup::SBody::getUserCount()
|
||||
{
|
||||
int nUserCount = 0;
|
||||
QSet<int> setId;
|
||||
QMapIterator<QString, stBody> iter(m_mapBody);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
if (setId.contains(iter.value().id_num))
|
||||
continue;
|
||||
|
||||
setId.insert(iter.value().id_num);
|
||||
|
||||
nUserCount++;
|
||||
}
|
||||
|
||||
return nUserCount;
|
||||
}
|
||||
|
||||
QMap<QString, int> SDatagroup::SBody::getMapBodyCountOfPlatform()
|
||||
{
|
||||
QMap<QString, int> mapBodyCountOfPlatform;
|
||||
QSet<QString> setUrl;
|
||||
QMapIterator<QString, stBody> iter(m_mapBody);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
if (setUrl.contains(iter.value().url))
|
||||
continue;
|
||||
|
||||
setUrl.insert(iter.key());
|
||||
|
||||
mapBodyCountOfPlatform[iter.value().platformname_name]++;
|
||||
}
|
||||
|
||||
return mapBodyCountOfPlatform;
|
||||
}
|
||||
|
||||
QMap<QString, int> SDatagroup::SBody::getMapUserCountOfPlatform()
|
||||
{
|
||||
QMap<QString, int> mapUserCountOfPlatform;
|
||||
QSet<int> setId;
|
||||
QMapIterator<QString, stBody> iter(m_mapBody);
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
if (setId.contains(iter.value().id_num))
|
||||
continue;
|
||||
|
||||
setId.insert(iter.value().id_num);
|
||||
|
||||
mapUserCountOfPlatform[iter.value().platformname_name]++;
|
||||
}
|
||||
|
||||
return mapUserCountOfPlatform;
|
||||
}
|
||||
|
||||
void SDatagroup::SReply::put(const QString &_url, const int &_order, const stReply &_streply)
|
||||
{
|
||||
|
||||
@@ -154,6 +154,10 @@ public:
|
||||
void setInitializer(SInitializer &initializer){ m_pSInitializer = &initializer; }
|
||||
stBody* get(const QString& _url);
|
||||
void clear();
|
||||
int getBodyCount();
|
||||
int getUserCount();
|
||||
QMap<QString, int> getMapBodyCountOfPlatform();
|
||||
QMap<QString, int> getMapUserCountOfPlatform();
|
||||
};
|
||||
|
||||
class SReply
|
||||
@@ -277,6 +281,10 @@ public:
|
||||
const stCommunity* getstCommunity(const QStringList& _sl);
|
||||
const stBodyReplyCount* getCounts();
|
||||
const stDate* getstDate();
|
||||
int getBodyCount();
|
||||
int getUserCount();
|
||||
QMap<QString, int> getMapBodyCountOfPlatform();
|
||||
QMap<QString, int> getMapUserCountOfPlatform();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <iostream>
|
||||
#include "sfilteralgorithm.h"
|
||||
#include "sfilterprocess.h"
|
||||
#include "shttpsender.h"
|
||||
#include "../Json/sjson.h"
|
||||
#include <QDebug>
|
||||
#include <QSqlDatabase>
|
||||
@@ -26,6 +27,25 @@ bool SFilterProcess::init(QString _strFilterProcessGroupID, QString _strFilterPr
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SFilterProcess::init(QString _strFilterProcessGroupID, QString _strFilterProcessGroupName, QString _strInfluencerLimit)
|
||||
{
|
||||
if (!m_SInitializer.init(_strFilterProcessGroupID, _strFilterProcessGroupName, _strInfluencerLimit))
|
||||
{
|
||||
cout << "initializer init error" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_SDatagroup.setInitializer(m_SInitializer);
|
||||
m_SConsumer.setInitiaizer(m_SInitializer);
|
||||
m_SInfluencer.setInitiaizer(m_SInitializer);
|
||||
m_SSpammer.setInitiaizer(m_SInitializer);
|
||||
m_SPowercafe.setInitiaizer(m_SInitializer);
|
||||
m_SConsumerMarketer.setInitiaizer(m_SInitializer);
|
||||
m_SConsumerCheckList.setInitiaizer(m_SInitializer);
|
||||
m_SInitializer.closeConnection(SDBManager::E_DATABASE_WEB);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SFilterProcess::run()
|
||||
{
|
||||
m_SInitializer.insertLog("New Filter start");
|
||||
@@ -74,22 +94,17 @@ bool SFilterProcess::run()
|
||||
}
|
||||
case E_PROCSS_TYPE_SEND:
|
||||
{
|
||||
m_SConsumerMarketer.makeTable(m_SDatagroup);
|
||||
m_SConsumerCheckList.makeTable(m_SDatagroup);
|
||||
m_SDatagroup.makeTable();
|
||||
|
||||
m_SConsumer.makeTable(m_SDatagroup);
|
||||
m_SInfluencer.makeTable(m_SDatagroup);
|
||||
m_SSpammer.makeTable(m_SDatagroup);
|
||||
m_SPowercafe.makeTable(m_SDatagroup);
|
||||
|
||||
if (m_SInitializer.isUpload())
|
||||
{
|
||||
m_SConsumerMarketer.makeTable(m_SDatagroup);
|
||||
m_SConsumerCheckList.makeTable(m_SDatagroup);
|
||||
m_SDatagroup.makeTable();
|
||||
|
||||
//m_SConsumer.makeOverallCategory(m_SInitializer.getAllCategoryNum(E_SERVICE_CONSUMER));
|
||||
//m_SInfluencer.makeOverallCategory(m_SInitializer.getAllCategoryNum(E_SERVICE_INFLUENCER));
|
||||
//m_SSpammer.makeOverallCategory(m_SInitializer.getAllCategoryNum(E_SERVICE_SPAMMER));
|
||||
//m_SPowercafe.makeOverallCategory(m_SInitializer.getAllCategoryNum(E_SERVICE_POWERCAFE));
|
||||
|
||||
m_SConsumer.makeTable(m_SDatagroup);
|
||||
m_SInfluencer.makeTable(m_SDatagroup);
|
||||
m_SSpammer.makeTable(m_SDatagroup);
|
||||
m_SPowercafe.makeTable(m_SDatagroup);
|
||||
|
||||
m_SInitializer.openConnection(SDBManager::E_DATABASE_WEB);
|
||||
m_SDatagroup.uploadData(process.m_nCompanyNum);
|
||||
m_SConsumer.uploadData(process.m_nCompanyNum);
|
||||
@@ -109,19 +124,22 @@ bool SFilterProcess::run()
|
||||
process.m_nCompanyNum);
|
||||
m_SInitializer.insertLog("Upload Done");
|
||||
m_nCompany = process.m_nCompanyNum;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nCompany = -100;
|
||||
m_SInitializer.insertLog("No Upload");
|
||||
}
|
||||
|
||||
m_SConsumer.SaveDataFile(process.m_nCompanyNum);
|
||||
m_SInfluencer.SaveDataFile(process.m_nCompanyNum);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_SInitializer.insertLog("New Filter END");
|
||||
m_SInitializer.insertLog("New Filter END.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
};
|
||||
SFilterProcess(QObject *parent = 0):QObject(parent), m_nCompany(-1){}
|
||||
bool init(QString _strFilterProcessGroupID, QString _strFilterProcessGroupName);
|
||||
bool init(QString _strFilterProcessGroupID, QString _strFilterProcessGroupName, QString _strInfluencerLimit);
|
||||
bool run();
|
||||
int getCompanyNum();
|
||||
};
|
||||
|
||||
@@ -78,6 +78,9 @@ SHttpSender::~SHttpSender()
|
||||
|
||||
void SHttpSender::SendData(int _company_num)
|
||||
{
|
||||
if (_company_num == -100)
|
||||
return;
|
||||
|
||||
QString strPort = "";
|
||||
if (port != 80)
|
||||
strPort = ":" + QString::number(static_cast<unsigned int>(port));
|
||||
@@ -106,7 +109,6 @@ void SHttpSender::SendData(int _company_num)
|
||||
//std::cout << "sent";
|
||||
}
|
||||
//qDebug() << data;
|
||||
|
||||
QTimer::singleShot(5000, this, SLOT(DisConnected()));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QFile>
|
||||
#include "sinfluencerinteractorurlmaker.h"
|
||||
#include "sinfluencer.h"
|
||||
|
||||
const double SInfluencer::SInfluencerWeight::m_multipleValue = 100.0/3;
|
||||
|
||||
void SInfluencer::setInitiaizer(SInitializer &_initializer)
|
||||
{
|
||||
m_pSInitializer = &_initializer;
|
||||
@@ -207,11 +211,61 @@ 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;
|
||||
}
|
||||
|
||||
QList<SInfluencer::stInfluencer>& SInfluencer::STInfluencer::getInfluencerList()
|
||||
{
|
||||
return m_listMap;
|
||||
}
|
||||
|
||||
bool SInfluencer::SaveDataFile(int _companyNum)
|
||||
{
|
||||
if (!m_STInfluencer.SaveDataFile(_companyNum))
|
||||
{
|
||||
m_pSInitializer->insertLog("influencer file save fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SInfluencer::STInfluencer::SaveDataFile(int _companyNum)
|
||||
{
|
||||
QString strFileName = QString::number(_companyNum) + "_Influencer_" + QDate::currentDate().toString("yyyyMMdd") + ".csv";
|
||||
QFile InfluecnerFile(strFileName);
|
||||
if (!InfluecnerFile.open(QFile::WriteOnly | QFile::Truncate))
|
||||
{
|
||||
//process
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream stream(&InfluecnerFile);
|
||||
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())
|
||||
{
|
||||
iter1.next();
|
||||
int nCategoryNum = iter1.key();
|
||||
const QList<stInfluencer> listInfluencer = iter1.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";
|
||||
}
|
||||
}
|
||||
|
||||
InfluecnerFile.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory)
|
||||
{
|
||||
const QMap<QString, QStringList>* mapBody = _datagroup.getmapBody();
|
||||
@@ -230,7 +284,6 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
{
|
||||
SDatagroup::stProfileurlKey stprofileurlkey(m_pSInitializer->getPlatformForm((*mapBody)[_url][anColumn[SInitializer::E_DATA_platform_form]].trimmed()),
|
||||
(*mapBody)[_url][anColumn[SInitializer::E_DATA_article_id]].trimmed());
|
||||
|
||||
if (!mapRank.contains(stprofileurlkey))
|
||||
{
|
||||
mapRank.insert(stprofileurlkey, stInfluencer());
|
||||
@@ -267,18 +320,61 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
mapRank[stprofileurlkey].replycount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//insert Reply
|
||||
const QMap<int, SDatagroup::stReply>* mapstReply = _datagroup.getstReply(_url);
|
||||
if (mapstReply == 0) continue;
|
||||
for (QMap<int, SDatagroup::stReply>::const_iterator iterPos1 = mapstReply->constBegin(); iterPos1 != mapstReply->constEnd(); iterPos1++)
|
||||
{
|
||||
SDatagroup::stReply ReplyInstance = iterPos1.value();
|
||||
//if (!ReplyInstance.realbycategorynum.contains(iterPos.key())) continue;
|
||||
|
||||
QString strId = ReplyInstance.id_id;
|
||||
if (mapRank[stprofileurlkey].id_id == strId) continue;
|
||||
|
||||
mapRank[stprofileurlkey].interactions[strId].append(ReplyInstance);
|
||||
mapRank[stprofileurlkey].interactionsTotalReplyCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
SIdrankbyinteraction idrankbyinteractionColumn;
|
||||
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;
|
||||
@@ -288,6 +384,31 @@ void SInfluencer::STInfluencer::makeTable(SDatagroup &_datagroup, const QMap<int
|
||||
}
|
||||
m_listMap.append(listmap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -338,6 +459,62 @@ bool SInfluencer::STInfluencer::uploadData(QSqlDatabase &_db, const int &_nCompa
|
||||
}
|
||||
*/
|
||||
|
||||
//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";
|
||||
@@ -349,44 +526,112 @@ bool SInfluencer::STInfluencer::uploadData(QSqlDatabase &_db, const int &_nCompa
|
||||
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,platformname_name) VALUES (";
|
||||
"_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)
|
||||
QMapIterator<int, QList<stInfluencer>> iter1(m_mapInfluencerOfCategory);
|
||||
while (iter1.hasNext())
|
||||
{
|
||||
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.platformname_name) + "')";
|
||||
|
||||
if (query.exec(str.toUtf8()) == false)
|
||||
iter1.next();
|
||||
const QList<stInfluencer>& listInfluencer = iter1.value();
|
||||
foreach (stInfluencer stinfluencer, listInfluencer)
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
strQuery = "update dbinfo set influencercount = " + QString::number(m_listMap.size()) + " where company_num = "
|
||||
|
||||
// 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)
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
|
||||
query.next();
|
||||
QString strInfluencerCount = query.value(0).toString();
|
||||
query.clear();
|
||||
|
||||
strQuery = "update dbinfo set influencercount = " + strInfluencerCount + " where company_num = "
|
||||
+ QString::number(_nCompany);
|
||||
query.exec(strQuery);
|
||||
|
||||
@@ -401,12 +646,14 @@ bool SInfluencer::STInfluencer::changeTable(QSqlDatabase &_db, const int &_nComp
|
||||
strQuery += "influencer_" + QString::number(_nCompany) + " TO " + "influencer_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "influencer_" + QString::number(_nCompany) + "_update" + " TO " + "influencer_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "influencer_" + QString::number(_nCompany) + "_temp" + " TO " + "influencer_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("influencer_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("influencer_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1050,12 +1297,14 @@ bool SInfluencer::SBodyInfluencerMap::changeTable(QSqlDatabase &_db, const int &
|
||||
strQuery += "body_influencer_map_" + QString::number(_nCompany) + " TO " + "body_influencer_map_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "body_influencer_map_" + QString::number(_nCompany) + "_update" + " TO " + "body_influencer_map_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "body_influencer_map_" + QString::number(_nCompany) + "_temp" + " TO " + "body_influencer_map_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("body_influencer_map_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("body_influencer_map_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1068,12 +1317,14 @@ bool SInfluencer::SReplyInfluencerMap::changeTable(QSqlDatabase &_db, const int
|
||||
strQuery += "reply_influencer_map_" + QString::number(_nCompany) + " TO " + "reply_influencer_map_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "reply_influencer_map_" + QString::number(_nCompany) + "_update" + " TO " + "reply_influencer_map_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "reply_influencer_map_" + QString::number(_nCompany) + "_temp" + " TO " + "reply_influencer_map_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("reply_influencer_map_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("reply_influencer_map_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1098,152 +1349,202 @@ struct stDate
|
||||
};
|
||||
|
||||
|
||||
void SInfluencer::SStatsJson::makeTable(SDatagroup &_datagroup, const QMap<int, stReal> &_mapCategory)
|
||||
//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)
|
||||
{
|
||||
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());
|
||||
//m_pSInitializer->insertLog((*mapBody)[strUrl][anColumn[SInitializer::E_DATA_article_date]].trimmed());
|
||||
QDate dBodyDate = QDateTime::fromString((*mapBody)[strUrl][anColumn[SInitializer::E_DATA_article_date]].trimmed().replace("T", " "), "yyyy-MM-dd hh:mm:ss").date();
|
||||
//m_pSInitializer->insertLog(dBodyDate.toString("yyyy-MM-dd"));
|
||||
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++)
|
||||
QList<int> listGroup = m_pSInitializer->getInfluencerGroup().keys();
|
||||
foreach (int nGroupNum, listGroup)
|
||||
{
|
||||
QString strPlatformName = _groupStatistics.getPlatform(nGroupNum);
|
||||
stStatsJson ststatsjson;
|
||||
ststatsjson.category_num = iterPos.key();
|
||||
ststatsjson.influencerGroupNum = nGroupNum;
|
||||
ststatsjson.platformname_num = 1;
|
||||
ststatsjson.servicenum = 1;
|
||||
ststatsjson.title = "info";
|
||||
ststatsjson.subtitle = "";
|
||||
ststatsjson.category_num = 0;
|
||||
ststatsjson.platformname_name = strPlatformName;
|
||||
ststatsjson.bodyCountOfPlatform = _platformStatistics.getBodyCount(strPlatformName);
|
||||
ststatsjson.userCount = _platformStatistics.getUserCount(strPlatformName);
|
||||
ststatsjson.jdata = makeStatsJson(ststatsjson);
|
||||
|
||||
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 nReply = 0;
|
||||
unsigned int nUser = 0;
|
||||
QJsonObject jsonObj;
|
||||
|
||||
foreach (const QString& strKey, setPlatformType)
|
||||
{
|
||||
if (strKey == "naver!@#blog")
|
||||
{
|
||||
// m_pSInitializer->insertLog(mapBodyDate.value(strKey).dStart.toString("yyyy-MM-dd"));
|
||||
// m_pSInitializer->insertLog(mapBodyDate.value(strKey).dEnd.toString("yyyy-MM-dd"));
|
||||
// m_pSInitializer->insertLog(QString::number(mapBodyDate.value(strKey).dStart.daysTo(mapBodyDate.value(strKey).dEnd)));
|
||||
nBody += ((mapBodyDate.value(strKey).dStart.daysTo(mapBodyDate.value(strKey).dEnd) + 1) * 1000);
|
||||
//nReply += (mapCount[strKey].reply * 1000);
|
||||
if (setPlatformType.size() == 1)
|
||||
jsonObj["pagenum"] = m_pSInitializer->getBlogPageNum();
|
||||
}
|
||||
else
|
||||
{
|
||||
nBody += mapCount[strKey].body;
|
||||
// nReply += mapCount[strKey].reply;
|
||||
}
|
||||
nUser += mapCount[strKey].id.size();
|
||||
}
|
||||
|
||||
/*
|
||||
unsigned int nRealBody = streal.m_setRealAllUrl.size();
|
||||
unsigned int nRealReply = 0;
|
||||
|
||||
foreach (const QString& strUrl, streal.m_setRealAllUrl)
|
||||
{
|
||||
if (mapReply->contains(strUrl))
|
||||
nRealReply += mapReply->value(strUrl).size();
|
||||
}
|
||||
*/
|
||||
|
||||
//unsigned int nInfluencerValue = (nRealBody == 0) ? 0 : nRealReply / nRealBody;
|
||||
unsigned int nTotalCount = nBody;
|
||||
jsonObj["totalcount"] = static_cast<int>(nTotalCount);
|
||||
jsonObj["totalusercount"] = static_cast<int>(nUser);
|
||||
//jsonObj["value"] = static_cast<long>(nInfluencerValue);
|
||||
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 = "";
|
||||
void SInfluencer::SStatsJson::makeTotalStatsJson(SPlatformStatistics _platformStatistics)
|
||||
{
|
||||
stStatsJson ststatsjson;
|
||||
ststatsjson.influencerGroupNum = -1;
|
||||
ststatsjson.platformname_num = 1;
|
||||
ststatsjson.servicenum = 1;
|
||||
ststatsjson.title = "info";
|
||||
ststatsjson.subtitle = "";
|
||||
ststatsjson.category_num = 0;
|
||||
ststatsjson.platformname_name = "";
|
||||
ststatsjson.bodyCountOfPlatform = _platformStatistics.getTotalBodyCount();
|
||||
ststatsjson.userCount = _platformStatistics.getTotalUserCount();
|
||||
ststatsjson.jdata = makeStatsJson(ststatsjson);
|
||||
|
||||
QSet<QString> setPlatformType;
|
||||
m_listMap.append(ststatsjson);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
QString SInfluencer::SStatsJson::makeStatsJson(stStatsJson _ststatsJson)
|
||||
{
|
||||
QJsonObject jsonObj;
|
||||
|
||||
unsigned int nBody = 0;
|
||||
unsigned int nUser = 0;
|
||||
QJsonObject jsonObj;
|
||||
jsonObj["totalcount"] = static_cast<int>(_ststatsJson.bodyCountOfPlatform);
|
||||
jsonObj["totalusercount"] = static_cast<int>(_ststatsJson.userCount);
|
||||
|
||||
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);
|
||||
}
|
||||
if (_ststatsJson.platformname_name == "naver")
|
||||
jsonObj["pagenum"] = m_pSInitializer->getBlogPageNum();
|
||||
else
|
||||
jsonObj["pagenum"] = -1;
|
||||
|
||||
QJsonDocument jsonDoc(jsonObj);
|
||||
|
||||
return jsonDoc.toJson();
|
||||
}
|
||||
|
||||
void SInfluencer::SStatsJson::makeTable(SDatagroup &_datagroup, STInfluencer& _influencer)
|
||||
{
|
||||
QList<stInfluencer>& listInfluencer = _influencer.getInfluencerList();
|
||||
|
||||
SPlatformStatistics platformStatistics;
|
||||
platformStatistics.calculatePlatformsStatistics(_datagroup);
|
||||
|
||||
SGroupStatistics groupStatistics(m_pSInitializer->getInfluencerGroup(), listInfluencer);
|
||||
groupStatistics.calculateGroupStatistics();
|
||||
|
||||
makeGroupStatsJson(groupStatistics, platformStatistics);
|
||||
makeTotalStatsJson(platformStatistics);
|
||||
}
|
||||
|
||||
bool SInfluencer::SStatsJson::uploadData(QSqlDatabase &_db, const int &_nCompany)
|
||||
@@ -1261,13 +1562,14 @@ bool SInfluencer::SStatsJson::uploadData(QSqlDatabase &_db, const int &_nCompany
|
||||
|
||||
foreach (const stStatsJson& ststats, m_listMap)
|
||||
{
|
||||
QString strQuery = "insert into stats_json (company_num, servicenum, title, subtitle, category_num, platformname_num, jdata) values (";
|
||||
QString strQuery = "insert into stats_json (company_num, servicenum, title, subtitle, platformname_num, category_num, categorygroup_num, jdata) values (";
|
||||
strQuery += QString::number(_nCompany) + ",";
|
||||
strQuery += QString::number(ststats.servicenum) + ",";
|
||||
strQuery += "'" + ststats.title + "',";
|
||||
strQuery += "'" + ststats.subtitle + "',";
|
||||
strQuery += QString::number(ststats.category_num) + ",";
|
||||
strQuery += QString::number(ststats.platformname_num) + ",";
|
||||
strQuery += QString::number(ststats.category_num) + ",";
|
||||
strQuery += QString::number(ststats.influencerGroupNum) + ",";
|
||||
strQuery += "'" + ststats.jdata +"')";
|
||||
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
@@ -1280,3 +1582,199 @@ bool SInfluencer::SStatsJson::uploadData(QSqlDatabase &_db, const int &_nCompany
|
||||
return true;
|
||||
}
|
||||
|
||||
void SInfluencer::SIdrankbyinteraction::makeInteractorsJson(const SInfluencer::stInfluencer& _val)
|
||||
{
|
||||
QMap<QString, QList<SDatagroup::stReply>> mapInteractions = _val.interactions;
|
||||
for (QMap<QString, QList<SDatagroup::stReply>>::const_iterator iterPos = mapInteractions.constBegin(); iterPos != mapInteractions.constEnd(); iterPos++)
|
||||
{
|
||||
QJsonObject interactionJson;
|
||||
QList<SDatagroup::stReply> listReplys = iterPos.value();
|
||||
QString strId = iterPos.key();
|
||||
interactionJson["id"] = strId;
|
||||
interactionJson["nickname"] = listReplys.at(0).nickname_nickname;
|
||||
interactionJson["count"] = listReplys.count();
|
||||
interactionJson["url"] = SInfluencerInteractorUrlMaker::makeInfluencerInteractorUrl(listReplys.at(0));
|
||||
m_interactorsJson.append(interactionJson);
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::SIdrankbyinteraction::pickInteractorsByHighReplyCount(int _pickLimit)
|
||||
{
|
||||
for (int i=0; i<_pickLimit; i++)
|
||||
{
|
||||
int maxReplyCount = 0;
|
||||
int maxReplyInteractionIndex;
|
||||
QJsonObject maxReplyInteraction;
|
||||
for (int j=0; j<m_interactorsJson.count(); j++)
|
||||
{
|
||||
QJsonObject targetObj = m_interactorsJson.at(j).toObject();
|
||||
int replyCount = targetObj["count"].toInt();
|
||||
if (replyCount >= maxReplyCount)
|
||||
{
|
||||
maxReplyCount = replyCount;
|
||||
maxReplyInteractionIndex = j;
|
||||
maxReplyInteraction = targetObj;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_interactorsJson.isEmpty())
|
||||
break;
|
||||
|
||||
m_pickedInteractorsJson.append(maxReplyInteraction);
|
||||
m_interactorsJson.removeAt(maxReplyInteractionIndex);
|
||||
}
|
||||
}
|
||||
|
||||
QString SInfluencer::SIdrankbyinteraction::makeIdrankbyinteractionColumnJson(const SInfluencer::stInfluencer& _val)
|
||||
{
|
||||
makeInteractorsJson(_val);
|
||||
pickInteractorsByHighReplyCount(10);
|
||||
|
||||
QJsonObject IdrankbyinteractionColumnJson;
|
||||
IdrankbyinteractionColumnJson["totalreplycount"] = _val.interactionsTotalReplyCount;
|
||||
IdrankbyinteractionColumnJson["totalcommentercount"] = _val.interactions.count();
|
||||
IdrankbyinteractionColumnJson["value"] = m_pickedInteractorsJson;
|
||||
|
||||
QJsonDocument finalResultJson(IdrankbyinteractionColumnJson);
|
||||
return finalResultJson.toJson();
|
||||
}
|
||||
|
||||
|
||||
void SInfluencer::SInfluencerWeight::calculateSectionWeight(QMap<int, double>& _mapSection)
|
||||
{
|
||||
int nTotalCount = _mapSection.count();
|
||||
double weightValue = 0.0;
|
||||
double accValue = 1.0/nTotalCount;
|
||||
|
||||
for (QMap<int, double>::iterator iter = _mapSection.begin(); iter != _mapSection.end(); iter++)
|
||||
{
|
||||
int nKey = iter.key();
|
||||
|
||||
_mapSection[nKey] = weightValue;
|
||||
weightValue += accValue;
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::SInfluencerWeight::calculateWeight()
|
||||
{
|
||||
calculateSectionWeight(m_mapBodyWeight);
|
||||
calculateSectionWeight(m_mapReplyWeight);
|
||||
calculateSectionWeight(m_mapLikeWeight);
|
||||
}
|
||||
|
||||
void SInfluencer::SInfluencerWeight::insert(stInfluencer &_val)
|
||||
{
|
||||
m_mapBodyWeight[_val.bodycount] = 0;
|
||||
m_mapReplyWeight[_val.replycount] = 0;
|
||||
m_mapLikeWeight[_val.likecount] = 0;
|
||||
}
|
||||
|
||||
double SInfluencer::SInfluencerWeight::getInfluenceValue(stInfluencer &_val)
|
||||
{
|
||||
double fBodyScore = m_mapBodyWeight[_val.bodycount];
|
||||
double fReplyScore = m_mapReplyWeight[_val.replycount];
|
||||
double fLikeScore = m_mapLikeWeight[_val.likecount];
|
||||
|
||||
return (fBodyScore + fReplyScore + fLikeScore) * m_multipleValue;
|
||||
}
|
||||
|
||||
void SInfluencer::SPlatformStatistics::calculatePlatformsStatistics(SDatagroup &_datagroup)
|
||||
{
|
||||
m_mapBodyCountOfPlatform = _datagroup.getMapBodyCountOfPlatform();
|
||||
m_mapUserCountOfPlatform = _datagroup.getMapUserCountOfPlatform();
|
||||
|
||||
m_nTotalBodyCount = _datagroup.getBodyCount();
|
||||
m_nTotalUserCount = _datagroup.getUserCount();
|
||||
}
|
||||
|
||||
|
||||
int SInfluencer::SPlatformStatistics::getBodyCount(QString _platformname)
|
||||
{
|
||||
if (m_mapBodyCountOfPlatform.contains(_platformname))
|
||||
return m_mapBodyCountOfPlatform[_platformname];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SInfluencer::SPlatformStatistics::getUserCount(QString _platformname)
|
||||
{
|
||||
if (m_mapUserCountOfPlatform.contains(_platformname))
|
||||
return m_mapUserCountOfPlatform[_platformname];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SInfluencer::SPlatformStatistics::getTotalBodyCount()
|
||||
{
|
||||
return m_nTotalBodyCount;
|
||||
}
|
||||
|
||||
int SInfluencer::SPlatformStatistics::getTotalUserCount()
|
||||
{
|
||||
return m_nTotalUserCount;
|
||||
}
|
||||
|
||||
void SInfluencer::SGroupStatistics::calculateUserCount()
|
||||
{
|
||||
for (QMap<int, QList<int>>::const_iterator iter = m_mapCategorysOfGroup.constBegin(); iter != m_mapCategorysOfGroup.constEnd(); iter++)
|
||||
{
|
||||
QList<int> listCategory = iter.value();
|
||||
|
||||
QSet<int> setInfluecnerIds;
|
||||
foreach (const stInfluencer& stinfluencer, m_listInfluencer)
|
||||
{
|
||||
if (!listCategory.contains(stinfluencer.category_num)) continue;
|
||||
|
||||
setInfluecnerIds.insert(stinfluencer.id_num);
|
||||
}
|
||||
m_mapUserCountOfGroup[iter.key()] = setInfluecnerIds.count();
|
||||
}
|
||||
}
|
||||
|
||||
void SInfluencer::SGroupStatistics::calculatePlatform()
|
||||
{
|
||||
for (QMap<int, QList<int>>::const_iterator iter = m_mapCategorysOfGroup.constBegin(); iter != m_mapCategorysOfGroup.constEnd(); iter++)
|
||||
{
|
||||
QList<int> listCategory = iter.value();
|
||||
|
||||
QMap<QString, int> mapBodyCountOfPlatform;
|
||||
foreach (const stInfluencer& stinfluencer, m_listInfluencer)
|
||||
{
|
||||
if (!listCategory.contains(stinfluencer.category_num)) continue;
|
||||
|
||||
mapBodyCountOfPlatform[stinfluencer.platformname_name]++;
|
||||
}
|
||||
|
||||
m_mapPlatformOfGroup[iter.key()] = getMaxBodyCountPlatform(mapBodyCountOfPlatform);
|
||||
}
|
||||
}
|
||||
|
||||
QString SInfluencer::SGroupStatistics::getMaxBodyCountPlatform(QMap<QString, int> _mapBodyCountOfPlatform)
|
||||
{
|
||||
int nMaxValue = 0;
|
||||
QString maxBodyCountPlatform;
|
||||
for (QMap<QString, int>::const_iterator iter = _mapBodyCountOfPlatform.constBegin(); iter != _mapBodyCountOfPlatform.constEnd(); iter++)
|
||||
{
|
||||
int nBodyCountOfPlatform = iter.value();
|
||||
if (nBodyCountOfPlatform >= nMaxValue)
|
||||
{
|
||||
nMaxValue = nBodyCountOfPlatform;
|
||||
maxBodyCountPlatform = iter.key();
|
||||
}
|
||||
}
|
||||
|
||||
return maxBodyCountPlatform;
|
||||
}
|
||||
|
||||
void SInfluencer::SGroupStatistics::calculateGroupStatistics()
|
||||
{
|
||||
calculatePlatform();
|
||||
}
|
||||
|
||||
QString SInfluencer::SGroupStatistics::getPlatform(int _nGroupNum)
|
||||
{
|
||||
if (m_mapPlatformOfGroup.contains(_nGroupNum))
|
||||
return m_mapPlatformOfGroup[_nGroupNum];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "sfilteralgorithm.h"
|
||||
#include "sinitializer.h"
|
||||
#include <QVector>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
class QString;
|
||||
class QStringList;
|
||||
class SInfluencer:public SService
|
||||
@@ -37,9 +40,12 @@ public:
|
||||
int platformname_num;
|
||||
int sharecount;
|
||||
int likecount;
|
||||
|
||||
QString interactionrank;
|
||||
QMap<QString, QList<SDatagroup::stReply>> interactions;
|
||||
int interactionsTotalReplyCount;
|
||||
int interactionsTotalCount;
|
||||
stInfluencer():id_num(0),nickname_num(0),community_num(0),category_num(0),bodycount(0),replycount(0),rank(0),influencervalue(0.0),platformname_num(0),
|
||||
sharecount(0), likecount(0){}
|
||||
sharecount(0), likecount(0), interactionsTotalReplyCount(0), interactionsTotalCount(0) {}
|
||||
|
||||
};
|
||||
struct stStatsInfBloggerRank
|
||||
@@ -110,12 +116,17 @@ public:
|
||||
private:
|
||||
SInitializer *m_pSInitializer;
|
||||
QList<stInfluencer> m_listMap;
|
||||
QMap<int, QList<stInfluencer>> m_mapInfluencerOfCategory;
|
||||
public:
|
||||
void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
|
||||
void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
||||
bool uploadData(QSqlDatabase &_db, const int &_nCompany);
|
||||
bool changeTable(QSqlDatabase &_db, const int &_nCompany);
|
||||
bool SaveDataFile(int _companyNum);
|
||||
void clear(){ m_listMap.clear(); }
|
||||
QList<stInfluencer>& getInfluencerList();
|
||||
int getInfluencerCount();
|
||||
QMap<QString, int> getInfluencerCountOfPlatform();
|
||||
};
|
||||
|
||||
class SStatsInfBloggerRank
|
||||
@@ -155,6 +166,21 @@ public:
|
||||
bool changeTable(QSqlDatabase &_db, const int &_nCompany);
|
||||
};
|
||||
|
||||
class SInfluencerWeight
|
||||
{
|
||||
private:
|
||||
QMap<int,double> m_mapBodyWeight;
|
||||
QMap<int,double> m_mapReplyWeight;
|
||||
QMap<int,double> m_mapLikeWeight;
|
||||
const static double m_multipleValue;
|
||||
|
||||
private:
|
||||
void calculateSectionWeight(QMap<int, double>& _mapSection);
|
||||
public:
|
||||
void calculateWeight();
|
||||
void insert(stInfluencer &_val);
|
||||
double getInfluenceValue(stInfluencer &_val);
|
||||
};
|
||||
|
||||
struct stStatsJson
|
||||
{
|
||||
@@ -162,10 +188,49 @@ public:
|
||||
int servicenum;
|
||||
QString title;
|
||||
QString subtitle;
|
||||
QString platformname_name;
|
||||
int platformname_num;
|
||||
QString jdata;
|
||||
int category_num;
|
||||
stStatsJson():company_num(0), servicenum(2), platformname_num(1), category_num(0){}
|
||||
int bodyCountOfPlatform;
|
||||
int userCount;
|
||||
int influencerGroupNum;
|
||||
stStatsJson():company_num(0), servicenum(2), platformname_num(1), category_num(0), bodyCountOfPlatform(0), userCount(0), influencerGroupNum(0){}
|
||||
};
|
||||
|
||||
class SPlatformStatistics
|
||||
{
|
||||
private:
|
||||
QMap<QString, int> m_mapBodyCountOfPlatform;
|
||||
QMap<QString, int> m_mapUserCountOfPlatform;
|
||||
int m_nTotalBodyCount;
|
||||
int m_nTotalUserCount;
|
||||
public:
|
||||
SPlatformStatistics() : m_nTotalBodyCount(0), m_nTotalUserCount(0) {}
|
||||
void calculatePlatformsStatistics(SDatagroup &_datagroup);
|
||||
int getBodyCount(QString _platformname);
|
||||
int getUserCount(QString _platformname);
|
||||
int getTotalBodyCount();
|
||||
int getTotalUserCount();
|
||||
};
|
||||
|
||||
class SGroupStatistics
|
||||
{
|
||||
private:
|
||||
QMap<int, int> m_mapUserCountOfGroup;
|
||||
QMap<int, QString> m_mapPlatformOfGroup;
|
||||
const QMap<int, QList<int>> m_mapCategorysOfGroup;
|
||||
const QList<SInfluencer::stInfluencer>& m_listInfluencer;
|
||||
|
||||
private:
|
||||
void calculateUserCount();
|
||||
void calculatePlatform();
|
||||
QString getMaxBodyCountPlatform(QMap<QString, int> _mapBodyCountOfPlatform);
|
||||
public:
|
||||
SGroupStatistics(QMap<int, QList<int>> _mapCategorysOfGroup, QList<SInfluencer::stInfluencer>& _listInfluencer) :
|
||||
m_mapCategorysOfGroup(_mapCategorysOfGroup), m_listInfluencer(_listInfluencer) {}
|
||||
void calculateGroupStatistics();
|
||||
QString getPlatform(int _nGroupNum);
|
||||
};
|
||||
|
||||
class SStatsJson
|
||||
@@ -173,13 +238,33 @@ public:
|
||||
private:
|
||||
SInitializer *m_pSInitializer;
|
||||
QList<stStatsJson> m_listMap;
|
||||
|
||||
private:
|
||||
void makeGroupStatsJson(SGroupStatistics _groupStatistics, SPlatformStatistics _platformStatistics);
|
||||
void makeTotalStatsJson(SPlatformStatistics _platformStatistics);
|
||||
QString makeStatsJson(stStatsJson _ststatsJson);
|
||||
|
||||
public:
|
||||
void setInitiaizer(SInitializer &_SInitializer) { m_pSInitializer = &_SInitializer; }
|
||||
void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
||||
// void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
||||
void makeTable(SDatagroup &_datagroup, STInfluencer& _influencer);
|
||||
bool uploadData(QSqlDatabase& _db, const int &_nCompany);
|
||||
void clear(){ m_listMap.clear(); }
|
||||
};
|
||||
|
||||
class SIdrankbyinteraction
|
||||
{
|
||||
private:
|
||||
QJsonArray m_interactorsJson;
|
||||
QJsonArray m_pickedInteractorsJson;
|
||||
|
||||
private:
|
||||
void makeInteractorsJson(const SInfluencer::stInfluencer& _val);
|
||||
void pickInteractorsByHighReplyCount(int _pickLimit);
|
||||
public:
|
||||
QString makeIdrankbyinteractionColumnJson(const SInfluencer::stInfluencer& _val);
|
||||
};
|
||||
|
||||
struct isGreaterInfluencerValue
|
||||
{
|
||||
bool operator()(const stInfluencer& first, const stInfluencer& second)
|
||||
@@ -204,6 +289,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct isGreaterInfluencerRank
|
||||
{
|
||||
bool operator()(const stInfluencer& first, const stInfluencer& second)
|
||||
{
|
||||
return first.rank <= second.rank;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct isGreaterBodyCount
|
||||
{
|
||||
bool operator()(const stStatsInfBloggerRank& first, const stStatsInfBloggerRank& second)
|
||||
@@ -227,6 +321,7 @@ public:
|
||||
return first.replycount > second.replycount;
|
||||
}
|
||||
};
|
||||
|
||||
struct stInfluenceBuzz
|
||||
{
|
||||
int bodycount;
|
||||
@@ -235,6 +330,7 @@ public:
|
||||
stInfluenceBuzz():bodycount(0), replycount(0) {}
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
SFilterAlgorithm m_SFilterAlgorithm;
|
||||
QMap<int, stReal> m_mapCategory;
|
||||
@@ -249,6 +345,7 @@ public:
|
||||
virtual void setInitiaizer(SInitializer &_initializer);
|
||||
virtual bool uploadData(int _companyNum);
|
||||
virtual bool changeTable(int _companyNum);
|
||||
virtual bool SaveDataFile(int _companyNum);
|
||||
virtual bool makeCategory(SDatagroup &_datagroup, int _nCategory, const QList<SInitializer::stFilter> &_listFilter);
|
||||
virtual bool makeOverallCategory(int _categoryNum);
|
||||
virtual bool makeTable(SDatagroup &_datagroup);
|
||||
|
||||
36
FilterProcess/sinfluencerinteractorurlmaker.cpp
Normal file
36
FilterProcess/sinfluencerinteractorurlmaker.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "sInfluencerInteractorUrlMaker.h"
|
||||
|
||||
const QString SInfluencerInteractorUrlMaker::m_strNaverBlogBaseUrl = QString("blog.naver.com/");
|
||||
const QString SInfluencerInteractorUrlMaker::m_strInstagramBaseUrl = QString("https://www.instagram.com/");
|
||||
const QString SInfluencerInteractorUrlMaker::m_strKakaoBaseUrl = QString("https://story.kakao.com/");
|
||||
const QString SInfluencerInteractorUrlMaker::m_strFacebookBaseUrl = QString("https://www.facebook.com/");
|
||||
|
||||
QString SInfluencerInteractorUrlMaker::makeInfluencerInteractorUrl(const SDatagroup::stReply& _interactorReply)
|
||||
{
|
||||
QString strInteractorUrl;
|
||||
QString strPlatformName = _interactorReply.platformname_name;
|
||||
QString strPlatformForm = _interactorReply.platformform_form;
|
||||
|
||||
if (strPlatformName == "naver" && strPlatformForm == "blog")
|
||||
{
|
||||
strInteractorUrl = SInfluencerInteractorUrlMaker::m_strNaverBlogBaseUrl + _interactorReply.id_id;
|
||||
}
|
||||
else if (strPlatformName == "instagram")
|
||||
{
|
||||
strInteractorUrl = SInfluencerInteractorUrlMaker::m_strInstagramBaseUrl + _interactorReply.id_id;
|
||||
}
|
||||
else if (strPlatformName == "kakaostory")
|
||||
{
|
||||
strInteractorUrl = SInfluencerInteractorUrlMaker::m_strKakaoBaseUrl + _interactorReply.id_id;
|
||||
}
|
||||
else if (strPlatformName == "facebook")
|
||||
{
|
||||
strInteractorUrl = SInfluencerInteractorUrlMaker::m_strFacebookBaseUrl + _interactorReply.id_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
strInteractorUrl = "";
|
||||
}
|
||||
|
||||
return strInteractorUrl;
|
||||
}
|
||||
26
FilterProcess/sinfluencerinteractorurlmaker.h
Normal file
26
FilterProcess/sinfluencerinteractorurlmaker.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef SINFLUENCERINTERACTORURLMAKER_H
|
||||
#define SINFLUENCERINTERACTORURLMAKER_H
|
||||
|
||||
#include <QString>
|
||||
#include "sdatagroup.h"
|
||||
|
||||
class SInfluencerInteractorUrlMaker
|
||||
{
|
||||
private:
|
||||
static const QString m_strNaverBlogBaseUrl;
|
||||
static const QString m_strInstagramBaseUrl;
|
||||
static const QString m_strKakaoBaseUrl;
|
||||
static const QString m_strFacebookBaseUrl;
|
||||
|
||||
public:
|
||||
static QString makeInfluencerInteractorUrl(const SDatagroup::stReply& _interactorReply);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // SINFLUENCERINTERACTORURLMAKER_H
|
||||
@@ -300,6 +300,39 @@ bool SInitializer::init(const QString& _strFilterProcessGroupID, const QString&
|
||||
return b_ok;
|
||||
}
|
||||
|
||||
bool SInitializer::init(const QString& _strFilterProcessGroupID, const QString& _strFilterProcessGroupName, QString _strInfluencerLimit)
|
||||
{
|
||||
m_stFilterProcessGroup.m_nFilterProcessGroupID = _strFilterProcessGroupID.toInt();
|
||||
m_stFilterProcessGroup.m_strFilterProcessGroupName = _strFilterProcessGroupName;
|
||||
m_strInfluencerLimitFrom = _strInfluencerLimit.split('~').first();
|
||||
m_strInfluencerLimitTo = _strInfluencerLimit.split('~').last();
|
||||
|
||||
bool b_ok = true;
|
||||
b_ok &= initDBConnection();
|
||||
b_ok &= initColumn();
|
||||
b_ok &= initDays();
|
||||
b_ok &= initInfluencer();
|
||||
b_ok &= initSpammer();
|
||||
b_ok &= initBlogPageNum();
|
||||
b_ok &= initFilterProcess();
|
||||
b_ok &= initCompanyNum();
|
||||
b_ok &= initPlatform();
|
||||
//b_ok &= initConsumerCategory();
|
||||
b_ok &= initCategory();
|
||||
b_ok &= initConsumerMarketer();
|
||||
b_ok &= initConsumerCheckList();
|
||||
b_ok &= initUpload();
|
||||
b_ok &= initDebug();
|
||||
|
||||
/*
|
||||
if (!b_ok)
|
||||
cout << "FALSE" << endl;
|
||||
else
|
||||
cout << "TRUE" << endl;
|
||||
*/
|
||||
return b_ok;
|
||||
}
|
||||
|
||||
bool SInitializer::initInfluencer()
|
||||
{
|
||||
m_stInfluencerParam.m_dBody = 0.4;
|
||||
@@ -396,6 +429,80 @@ bool SInitializer::initFilterProcess()
|
||||
return true;
|
||||
}
|
||||
|
||||
//bool SInitializer::initCategory()
|
||||
//{
|
||||
// for (int i = 0; i < E_SERVICE_MAX; i++)
|
||||
// {
|
||||
// m_anAllCategory[i] = -1;
|
||||
// }
|
||||
// int company_num = -1;
|
||||
// foreach (const stFilterProcess& stfilterprocess, m_listFilterProcess)
|
||||
// {
|
||||
// if (stfilterprocess.m_nFilterProcessType == 2)
|
||||
// {
|
||||
// company_num = stfilterprocess.m_nCompanyNum;
|
||||
// }
|
||||
// }
|
||||
// if (company_num == -1)
|
||||
// return false;
|
||||
|
||||
// QSqlQuery query(m_sDBManager[SDBManager::E_DATABASE_WEB]);
|
||||
|
||||
// QString strQuery = "select num, servicenum, name from category where company_num = ";
|
||||
// strQuery += QString::number(company_num) + " order by servicenum asc, num asc";
|
||||
|
||||
// if (query.exec(strQuery.toUtf8()) == false)
|
||||
// {
|
||||
// insertLog(query.lastQuery());
|
||||
// insertLog(query.lastError().text());
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// int nService[E_SERVICE_MAX] = {0,};
|
||||
|
||||
// while(query.next())
|
||||
// {
|
||||
// m_mapCategory.insert(query.value(0).toInt(), query.value(2).toString());
|
||||
|
||||
// switch(query.value(1).toInt())
|
||||
// {
|
||||
// case E_SERVICE_INFLUENCER:
|
||||
// {
|
||||
// if (0 == nService[E_SERVICE_INFLUENCER]++)
|
||||
// {
|
||||
// m_anAllCategory[E_SERVICE_INFLUENCER] = query.value(0).toInt();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case E_SERVICE_CONSUMER:
|
||||
// {
|
||||
// if (0 == nService[E_SERVICE_CONSUMER]++)
|
||||
// {
|
||||
// m_anAllCategory[E_SERVICE_CONSUMER] = query.value(0).toInt();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case E_SERVICE_SPAMMER:
|
||||
// {
|
||||
// if (0 == nService[E_SERVICE_SPAMMER]++)
|
||||
// {
|
||||
// m_anAllCategory[E_SERVICE_SPAMMER] = query.value(0).toInt();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case E_SERVICE_POWERCAFE:
|
||||
// {
|
||||
// if (0 == nService[E_SERVICE_POWERCAFE]++)
|
||||
// {
|
||||
// m_anAllCategory[E_SERVICE_POWERCAFE] = query.value(0).toInt();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
|
||||
bool SInitializer::initCategory()
|
||||
{
|
||||
for (int i = 0; i < E_SERVICE_MAX; i++)
|
||||
@@ -415,7 +522,7 @@ bool SInitializer::initCategory()
|
||||
|
||||
QSqlQuery query(m_sDBManager[SDBManager::E_DATABASE_WEB]);
|
||||
|
||||
QString strQuery = "select num, servicenum, name from category where company_num = ";
|
||||
QString strQuery = "select num, servicenum, name, categorygroup_num from category where company_num = ";
|
||||
strQuery += QString::number(company_num) + " order by servicenum asc, num asc";
|
||||
|
||||
if (query.exec(strQuery.toUtf8()) == false)
|
||||
@@ -439,6 +546,9 @@ bool SInitializer::initCategory()
|
||||
{
|
||||
m_anAllCategory[E_SERVICE_INFLUENCER] = query.value(0).toInt();
|
||||
}
|
||||
|
||||
m_mapInfluencerGroup[query.value(3).toInt()].append(query.value(0).toInt());
|
||||
|
||||
break;
|
||||
}
|
||||
case E_SERVICE_CONSUMER:
|
||||
@@ -828,3 +938,17 @@ int SInitializer::getAllCategoryNum(int _nService)
|
||||
return m_anAllCategory[_nService];
|
||||
}
|
||||
|
||||
QMap<int, QList<int>> SInitializer::getInfluencerGroup()
|
||||
{
|
||||
return m_mapInfluencerGroup;
|
||||
}
|
||||
|
||||
QString SInitializer::getInfluencerLimitFrom()
|
||||
{
|
||||
return m_strInfluencerLimitFrom;
|
||||
}
|
||||
|
||||
QString SInitializer::getInfluencerLimitTo()
|
||||
{
|
||||
return m_strInfluencerLimitTo;
|
||||
}
|
||||
|
||||
@@ -199,12 +199,16 @@ private:
|
||||
int m_nBlogPageNum;
|
||||
QMap<int, QString> m_mapConsumerMaketers;
|
||||
QMap<int, QString> m_mapConsumerCheckListUser;
|
||||
QMap<int, QList<int>> m_mapInfluencerGroup;
|
||||
QStringList m_slConsumerCheckList;
|
||||
bool m_bUpload;
|
||||
bool m_bDebug;
|
||||
QString m_strInfluencerLimitFrom;
|
||||
QString m_strInfluencerLimitTo;
|
||||
|
||||
public:
|
||||
bool init(const QString& _strFilterProcessGroupID, const QString& _strFilterProcessGroupName);
|
||||
bool init(const QString& _strFilterProcessGroupID, const QString& _strFilterProcessGroupName, QString _strInfluencerLimit);
|
||||
void insertLog(const QString& _strMsg) const;
|
||||
void insertDebugLog(const QString& _strMsg) const;
|
||||
QSqlDatabase getDatabase(const QString& _dbName) const;
|
||||
@@ -239,6 +243,9 @@ public:
|
||||
QStringList getConsumerCheckList();
|
||||
QMap<int, QString> getConsumerCheckListUser();
|
||||
bool isUpload();
|
||||
QMap<int, QList<int>> getInfluencerGroup();
|
||||
QString getInfluencerLimitFrom();
|
||||
QString getInfluencerLimitTo();
|
||||
//bool disableIndex(QSqlDatabase& db, QString _tableName, QStringList _strIndexNames, int _nMode = MODE);
|
||||
//bool enableIndex(QSqlDatabase& db, QString _tableName, QStringList _strIndexNames, int _nMode = MODE);
|
||||
//bool disableSettings(QSqlDatabase& db, int _nMode = MODE);
|
||||
|
||||
@@ -547,12 +547,14 @@ bool SPowercafe::STPowercafe::changeTable(QSqlDatabase &_db, const int &_nCompan
|
||||
strQuery += "powercafe_" + QString::number(_nCompany) + " TO " + "powercafe_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "powercafe_" + QString::number(_nCompany) + "_update" + " TO " + "powercafe_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "powercafe_" + QString::number(_nCompany) + "_temp" + " TO " + "powercafe_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("powercafe_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("powercafe_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -849,12 +851,14 @@ bool SPowercafe::SBodyPowercafeMap::changeTable(QSqlDatabase &_db, const int &_n
|
||||
strQuery += "body_powercafe_map_" + QString::number(_nCompany) + " TO " + "body_powercafe_map_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "body_powercafe_map_" + QString::number(_nCompany) + "_update" + " TO " + "body_powercafe_map_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "body_powercafe_map_" + QString::number(_nCompany) + "_temp" + " TO " + "body_powercafe_map_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("body_powercafe_map_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("body_powercafe_map_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -866,12 +870,14 @@ bool SPowercafe::SReplyPowercafeMap::changeTable(QSqlDatabase &_db, const int &_
|
||||
strQuery += "reply_powercafe_map_" + QString::number(_nCompany) + " TO " + "reply_powercafe_map_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "reply_powercafe_map_" + QString::number(_nCompany) + "_update" + " TO " + "reply_powercafe_map_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "reply_powercafe_map_" + QString::number(_nCompany) + "_temp" + " TO " + "reply_powercafe_map_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("reply_powercafe_map_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("reply_powercafe_map_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -388,12 +388,14 @@ bool SSpammer::STSpammer::changeTable(QSqlDatabase &_db, const int &_nCompany)
|
||||
strQuery += "spammer_" + QString::number(_nCompany) + " TO " + "spammer_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "spammer_" + QString::number(_nCompany) + "_update" + " TO " + "spammer_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "spammer_" + QString::number(_nCompany) + "_temp" + " TO " + "spammer_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("spammer_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("spammer_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -823,12 +825,14 @@ bool SSpammer::SBodySpammerMap::changeTable(QSqlDatabase &_db, const int &_nComp
|
||||
strQuery += "body_spammer_map_" + QString::number(_nCompany) + " TO " + "body_spammer_map_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "body_spammer_map_" + QString::number(_nCompany) + "_update" + " TO " + "body_spammer_map_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "body_spammer_map_" + QString::number(_nCompany) + "_temp" + " TO " + "body_spammer_map_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("body_spammer_map_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("body_spammer_map_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -841,12 +845,14 @@ bool SSpammer::SReplySpammerMap::changeTable(QSqlDatabase &_db, const int &_nCom
|
||||
strQuery += "reply_spammer_map_" + QString::number(_nCompany) + " TO " + "reply_spammer_map_" + QString::number(_nCompany) + "_temp" + ",";
|
||||
strQuery += "reply_spammer_map_" + QString::number(_nCompany) + "_update" + " TO " + "reply_spammer_map_" + QString::number(_nCompany) + ",";
|
||||
strQuery += "reply_spammer_map_" + QString::number(_nCompany) + "_temp" + " TO " + "reply_spammer_map_" + QString::number(_nCompany) + "_update";
|
||||
m_pSInitializer->insertLog("reply_spammer_map_" + QString::number(_nCompany) + " rename table start");
|
||||
if (!query.exec(strQuery.toUtf8()))
|
||||
{
|
||||
m_pSInitializer->insertLog(query.lastQuery());
|
||||
m_pSInitializer->insertLog(query.lastError().text());
|
||||
return false;
|
||||
}
|
||||
m_pSInitializer->insertLog("reply_spammer_map_" + QString::number(_nCompany) + " rename table end");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user