374 lines
13 KiB
C++
374 lines
13 KiB
C++
#ifndef SINFLUENCER
|
|
#define SINFLUENCER
|
|
#include "sservice.h"
|
|
#include "sfilteralgorithm.h"
|
|
#include "sinitializer.h"
|
|
#include <QVector>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
|
|
class QString;
|
|
class QStringList;
|
|
class SInfluencer:public SService
|
|
{
|
|
public:
|
|
struct stReal
|
|
{
|
|
QSet<QString> m_setRealAllUrl;
|
|
QSet<QString> m_setRealBodyUrl;
|
|
QMap<QString, int> m_mapRealReplyUniqueUrl; //multiple
|
|
};
|
|
struct stInfluencer
|
|
{
|
|
int id_num;
|
|
int nickname_num;
|
|
int community_num;
|
|
int category_num;
|
|
QString id_id;
|
|
QString profile;
|
|
QString profileurl;
|
|
int bodycount;
|
|
int replycount;
|
|
double influencervalue;
|
|
int rank;
|
|
QString community_title;
|
|
QString community_url;
|
|
QString community_id;
|
|
QString nickname_nickname;
|
|
QString nickname_exnickname;
|
|
QString platformname_name;
|
|
int platformname_num;
|
|
int sharecount;
|
|
int likecount;
|
|
QString interactionrank;
|
|
QString isSelected;
|
|
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), interactionsTotalReplyCount(0), interactionsTotalCount(0), isSelected("NULL") {}
|
|
|
|
};
|
|
struct stStatsInfBloggerRank
|
|
{
|
|
QString id_id;
|
|
QString nickname_nickname;
|
|
int bodycount;
|
|
int replycount;
|
|
double influencevalue;
|
|
QString subject;
|
|
int company_num;
|
|
int rank;
|
|
stStatsInfBloggerRank():bodycount(0),replycount(0),rank(0),influencevalue(0.0){}
|
|
stStatsInfBloggerRank(const QString &_id_id, const QString &_nickname_nickname):id_id(_id_id),nickname_nickname(_nickname_nickname),
|
|
bodycount(0), replycount(0), rank(0), influencevalue(0.0) {}
|
|
};
|
|
|
|
struct stStatsInfBloggerBuzzbyday
|
|
{
|
|
QString date;
|
|
int formateddate;
|
|
int idcount;
|
|
int bodycount;
|
|
int replycount;
|
|
int company_num;
|
|
stStatsInfBloggerBuzzbyday():formateddate(0), idcount(0), bodycount(0), replycount(0), company_num(0){}
|
|
};
|
|
|
|
struct stBodyInfluencerMap
|
|
{
|
|
int num;
|
|
int body_num;
|
|
int id_num;
|
|
int category_num;
|
|
int realin;
|
|
int community_num;
|
|
QString date;
|
|
stBodyInfluencerMap():num(0),body_num(0), id_num(0), category_num(0), realin(0), community_num(0){}
|
|
};
|
|
struct stReplyInfluencerMap
|
|
{
|
|
int num;
|
|
int reply_num;
|
|
int body_num;
|
|
int id_num;
|
|
int category_num;
|
|
int realin;
|
|
int community_num;
|
|
QString body_date;
|
|
stReplyInfluencerMap():num(0),reply_num(0),body_num(0),id_num(0),category_num(0),realin(0),community_num(0){}
|
|
};
|
|
|
|
class SReplyInfluencerMap
|
|
{
|
|
private:
|
|
SInitializer *m_pSInitializer;
|
|
QList<stReplyInfluencerMap> m_listMap;
|
|
public:
|
|
void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
|
|
void clear(){ m_listMap.clear(); }
|
|
void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
|
bool uploadData(QSqlDatabase &_db, const int &_nCompany);
|
|
bool changeTable(QSqlDatabase &_db, const int &_nCompany);
|
|
};
|
|
|
|
class STInfluencer
|
|
{
|
|
private:
|
|
SInitializer *m_pSInitializer;
|
|
QList<stInfluencer> m_listMap;
|
|
QMap<int, QList<stInfluencer>> m_mapInfluencerOfCategory;
|
|
QMap<int, QList<int>> m_mapInfluencerGroupInfo;
|
|
QMap<int, QMap<int, QList<stInfluencer>>> m_mapInfluencerOfGroup;
|
|
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();
|
|
int getInfluencerGroupNum(int _nCategoryNum);
|
|
void setInfluencerValueWieght();
|
|
void processDuplicatedInfluencer();
|
|
QMap<QString, QList<double>> makeInfluencerValuesOfId(QMap<int, QList<stInfluencer>> &_mapInfluencersOfCategory);
|
|
QMap<QString, QList<double>> filterInfluencerValuesOfId(QMap<QString, QList<double>> &_mapInfluencerValuesOfId);
|
|
void sortInfluencerValuesOfId(QMap<QString, QList<double>> &_mapInfluencerValuesOfId);
|
|
void copyInfluencerFromGroupToList();
|
|
void sortInfluencerByValue();
|
|
void setInfluecnerRank();
|
|
void setDuplicatedInfluencerFlag(QMap<int, QList<stInfluencer>> &_mapInfluencersOfCategory, QMap<QString, QList<double>> &_mapInfluencerValuesOfId);
|
|
void setGroupDuplicatedInfluencerFlag(QMap<QString, int> &_mapCountOfGroupDuplicatedId);
|
|
QMap<QString, int> makeCountOfGroupDuplicatedId();
|
|
};
|
|
|
|
class SStatsInfBloggerRank
|
|
{
|
|
private:
|
|
SInitializer *m_pSInitializer;
|
|
QList<stStatsInfBloggerRank> m_listMap;
|
|
public:
|
|
void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
|
|
void clear(){ m_listMap.clear(); }
|
|
void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
|
bool uploadData(QSqlDatabase &_db, const int &_nCompany);
|
|
};
|
|
|
|
class SStatsInfBloggerBuzzbyday
|
|
{
|
|
private:
|
|
SInitializer *m_pSInitializer;
|
|
QList<stStatsInfBloggerBuzzbyday> m_listMap;
|
|
public:
|
|
void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
|
|
void clear(){ m_listMap.clear(); }
|
|
void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
|
bool uploadData(QSqlDatabase &_db, const int &_nCompany);
|
|
};
|
|
|
|
class SBodyInfluencerMap
|
|
{
|
|
private:
|
|
SInitializer *m_pSInitializer;
|
|
QList<stBodyInfluencerMap> m_listMap;
|
|
public:
|
|
void setInitiaizer(SInitializer &_initializer){ m_pSInitializer = &_initializer; }
|
|
void clear(){ m_listMap.clear(); }
|
|
void makeTable(SDatagroup &_datagroup, const QMap<int, stReal>& _mapCategory);
|
|
bool uploadData(QSqlDatabase &_db, const int &_nCompany);
|
|
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
|
|
{
|
|
int company_num;
|
|
int servicenum;
|
|
QString title;
|
|
QString subtitle;
|
|
QString platformname_name;
|
|
int platformname_num;
|
|
QString jdata;
|
|
int category_num;
|
|
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
|
|
{
|
|
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, 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)
|
|
{
|
|
if (first.influencervalue > second.influencervalue)
|
|
return true;
|
|
else if (first.influencervalue == second.influencervalue)
|
|
return first.bodycount > second.bodycount;
|
|
else
|
|
return false;
|
|
//return first.influencervalue > second.influencervalue;
|
|
}
|
|
bool operator()(const stStatsInfBloggerRank& first, const stStatsInfBloggerRank& second)
|
|
{
|
|
if (first.influencevalue > second.influencevalue)
|
|
return true;
|
|
else if (first.influencevalue == second.influencevalue)
|
|
return first.bodycount > second.bodycount;
|
|
else
|
|
return false;
|
|
//return first.influencevalue > second.influencevalue;
|
|
}
|
|
};
|
|
|
|
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)
|
|
{
|
|
return first.bodycount > second.bodycount;
|
|
}
|
|
bool operator()(const stInfluencer& first, const stInfluencer& second)
|
|
{
|
|
return first.bodycount > second.bodycount;
|
|
}
|
|
};
|
|
|
|
struct isGreaterReplyCount
|
|
{
|
|
bool operator()(const stStatsInfBloggerRank& first, const stStatsInfBloggerRank& second)
|
|
{
|
|
return first.replycount > second.replycount;
|
|
}
|
|
bool operator()(const stInfluencer& first, const stInfluencer& second)
|
|
{
|
|
return first.replycount > second.replycount;
|
|
}
|
|
};
|
|
|
|
struct stInfluenceBuzz
|
|
{
|
|
int bodycount;
|
|
int replycount;
|
|
QSet<QString> idcount;
|
|
stInfluenceBuzz():bodycount(0), replycount(0) {}
|
|
};
|
|
|
|
|
|
private:
|
|
SFilterAlgorithm m_SFilterAlgorithm;
|
|
QMap<int, stReal> m_mapCategory;
|
|
SBodyInfluencerMap m_SBodyInfluencerMap;
|
|
SReplyInfluencerMap m_SReplyInfluencerMap;
|
|
//SStatsInfBloggerBuzzbyday m_SStatsInfBloggerBuzzbyday;
|
|
//SStatsInfBloggerRank m_SStatsInfBloggerRank;
|
|
STInfluencer m_STInfluencer;
|
|
SStatsJson m_SStatsJson;
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
#endif // SINFLUENCER
|
|
|