까페 카운터 기능 추가
git-svn-id: svn://192.168.0.12/source@59 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -61,9 +61,16 @@ Widget::Widget(QWidget *parent) : C_MAP_REAL_BODY (0x01) , C_MAP_REAL_REPLY (0x0
|
||||
hLayoutEdit->addWidget(m_pleCycle);
|
||||
m_pleCycle->setText("172800");
|
||||
m_pleCycle->setEnabled(false);
|
||||
QPushButton *ppbCount = new QPushButton("Count");
|
||||
connect(ppbCount, SIGNAL(released()),this, SLOT(on_count()));
|
||||
hLayoutEdit->addWidget(ppbCount);
|
||||
{
|
||||
QPushButton *ppbCount = new QPushButton("Influence Count");
|
||||
connect(ppbCount, SIGNAL(released()),this, SLOT(on_influence_count()));
|
||||
hLayoutEdit->addWidget(ppbCount);
|
||||
}
|
||||
{
|
||||
QPushButton *ppbCount = new QPushButton("Power Cafe Count");
|
||||
connect(ppbCount, SIGNAL(released()),this, SLOT(on_power_cafe_count()));
|
||||
hLayoutEdit->addWidget(ppbCount);
|
||||
}
|
||||
QPushButton *ppbInsert = new QPushButton("Insert");
|
||||
connect(ppbInsert, SIGNAL(released()),this, SLOT(on_insert()));
|
||||
hLayoutEdit->addWidget(ppbInsert);
|
||||
@@ -930,7 +937,7 @@ void Widget::DataPut(QString _strCompanyNum)
|
||||
if(query.exec(strQuery.toUtf8()) == false) {InsertLog(query.lastError().text());return;}
|
||||
|
||||
QString strReplyQuery = QString("insert into reply_" + _strCompanyNum + " (num,id,nickname,parent,data,date,body_num,realbycategorynum) VALUES (:NUM,:ID,:NICKNAME,:PARENT,:DATA,:DATE,:BODY_NUM,:REALBYCATEGORYNUM)").toUtf8();
|
||||
QString strBodyQuery = QString("insert into body_" + _strCompanyNum + " (num,platformname,platformform,platformtitle,id,nickname,title,data,profileurl,url,hit,date,reply_startnum,reply_endnum,lastupdate,realbycategorynum) VALUES (:NUM,:PLATFORMNAME,:PLATFORMFORM,:PLATFORMTITLE,:ID,:NICKNAME,:TITLE,:DATA,:PROFILEURL,:URL,:VIEW,:DATE,:REPLY_STARTNUM,:REPLY_ENDNUM,:LASTUPDATE,:REALBYCATEGORYNUM)").toUtf8();
|
||||
QString strBodyQuery = QString("insert into body_" + _strCompanyNum + " (num,platformname,platformform,platformtitle,id,nickname,title,data,profileurl,url,hit,date,reply_startnum,reply_endnum,lastupdate,realbycategorynum,profile) VALUES (:NUM,:PLATFORMNAME,:PLATFORMFORM,:PLATFORMTITLE,:ID,:NICKNAME,:TITLE,:DATA,:PROFILEURL,:URL,:VIEW,:DATE,:REPLY_STARTNUM,:REPLY_ENDNUM,:LASTUPDATE,:REALBYCATEGORYNUM,'')").toUtf8();
|
||||
QString strMapQuery = QString("insert into body_category_map_" + _strCompanyNum + " (num,body_num,category_num,realin) VALUES (:NUM,:BODY_NUM,:CATEGORY_NUM,:REALIN)").toUtf8();
|
||||
|
||||
int nReplyCount = 0;
|
||||
@@ -1020,8 +1027,8 @@ void Widget::DataPut(QString _strCompanyNum)
|
||||
foreach(SBuzzy stBuzzy,m_vecBuzzy)
|
||||
{
|
||||
SBuzzyCount stCount;
|
||||
stCount.m_nCategory = stBuzzy.m_nCategory;
|
||||
memset(&stCount.m_anCount,0,sizeof(int)*D_ARTICLE_MAX);
|
||||
stCount.m_nCategory = stBuzzy.m_nCategory;
|
||||
if (stBuzzy.m_astArticle[E_ARTICLE_BODY].m_mapCount.contains(date))
|
||||
stCount.m_anCount[0] = stBuzzy.m_astArticle[E_ARTICLE_BODY].m_mapCount[date];
|
||||
if (stBuzzy.m_astArticle[E_ARTICLE_REPLY].m_mapCount.contains(date))
|
||||
@@ -1031,11 +1038,14 @@ void Widget::DataPut(QString _strCompanyNum)
|
||||
}
|
||||
for (int i = 0; i < D_ARTICLE_MAX ; i++)
|
||||
{
|
||||
strQuery = "insert stats_articlebuzzbyday set ";
|
||||
strQuery = "insert stats_articlebuzzbyday set ";
|
||||
foreach(SBuzzyCount stCount,vecCount)
|
||||
{
|
||||
strQuery += "category_";
|
||||
strQuery += QString::number(stCount.m_nCategory);
|
||||
if (stCount.m_nCategory)
|
||||
strQuery += QString::number(stCount.m_nCategory);
|
||||
else
|
||||
strQuery += "all";
|
||||
strQuery += " = ";
|
||||
strQuery += QString::number(stCount.m_anCount[i]);
|
||||
strQuery += ",";
|
||||
@@ -1056,6 +1066,103 @@ void Widget::DataPut(QString _strCompanyNum)
|
||||
db.close();
|
||||
}
|
||||
|
||||
bool QSortPowerCafe(const SPowerCafeCount &st1, const SPowerCafeCount &st2)
|
||||
{
|
||||
return st1.m_ncAll > st2.m_ncAll;
|
||||
}
|
||||
|
||||
void Widget::on_power_cafe_count()
|
||||
{
|
||||
QMap <QString,SPowerCafeCount> mapCount;
|
||||
foreach (QListWidgetItem *item,m_plw[E_LIST_COMPANY].selectedItems())
|
||||
{
|
||||
InsertLog("Power Cafe Rank Count Make Start " + item->text());
|
||||
QString strCompanyNum = item->data(Qt::UserRole).toString();
|
||||
foreach(SBody stBody, m_mapData.values())
|
||||
{
|
||||
if (stBody.m_strlist[m_anData[E_DATA_platform_form]].trimmed().compare(QString("cafe")) != 0) continue;
|
||||
QString strKey = stBody.m_strlist[m_anData[E_DATA_platform_id]];
|
||||
if (mapCount.contains(strKey)==false)
|
||||
{
|
||||
SPowerCafeCount stPowerCafe;
|
||||
stPowerCafe.m_ncBodyAll = 0;
|
||||
stPowerCafe.m_ncReplyAll = 0;
|
||||
stPowerCafe.m_strCafeID = strKey;
|
||||
stPowerCafe.m_strTitle = stBody.m_strlist[m_anData[E_DATA_platform_title]];
|
||||
mapCount.insert(strKey,stPowerCafe);
|
||||
}
|
||||
mapCount[strKey].m_ncBodyAll++;
|
||||
if (mapCount[strKey].m_mapUser.contains(stBody.m_strlist[m_anData[E_DATA_article_id]])==false)
|
||||
mapCount[strKey].m_mapUser.insert(stBody.m_strlist[m_anData[E_DATA_article_id]],true);
|
||||
foreach(SReply stReply , stBody.m_vecReply.values())
|
||||
{
|
||||
if (stReply.m_strlist[m_anData[E_DATA_article_id]].compare(strKey) != 0)
|
||||
mapCount[strKey].m_ncReplyAll++;
|
||||
if (mapCount[strKey].m_mapUser.contains(stReply.m_strlist[m_anData[E_DATA_article_id]])==false)
|
||||
mapCount[strKey].m_mapUser.insert(stReply.m_strlist[m_anData[E_DATA_article_id]],true);
|
||||
}
|
||||
}
|
||||
foreach (SPowerCafeCount stPowerCafe,mapCount.values())
|
||||
{
|
||||
mapCount[stPowerCafe.m_strCafeID].m_ncAll = stPowerCafe.m_ncBodyAll + stPowerCafe.m_ncReplyAll;
|
||||
}
|
||||
InsertLog("Power Cafe Rank Count Make End");
|
||||
{
|
||||
db.setHostName(D_DB_WEB_HOST);
|
||||
db.setUserName(D_DB_WEB_USER);
|
||||
db.setPassword(D_DB_WEB_PASS);
|
||||
db.setDatabaseName(D_DB_WEB_NAME);
|
||||
if (db.open() == false)
|
||||
{
|
||||
InsertLog(db.lastError().text());
|
||||
return;
|
||||
}
|
||||
|
||||
InsertLog("Power Cafe Rank Count Send Start");
|
||||
QSqlQuery query;
|
||||
QString strQuery;
|
||||
strQuery = "delete from powercafe where company_num = " + strCompanyNum;
|
||||
if(query.exec(strQuery.toUtf8()) == false) {InsertLog(query.lastError().text());return;}
|
||||
strQuery = "delete from stats_powercaferank where company_num = " + strCompanyNum;
|
||||
if(query.exec(strQuery.toUtf8()) == false) {InsertLog(query.lastError().text());return;}
|
||||
QList<SPowerCafeCount> list = mapCount.values();
|
||||
qSort(list.begin(),list.end(),QSortPowerCafe);
|
||||
|
||||
strQuery = "insert into powercafe (company_num,usercountreal,bodycountreal,replycountreal,allcountreal,id,title,url,bodycountall,replycountall,allcountall,usercountall)"
|
||||
" VALUES (" + strCompanyNum + ",0,0,0,0,:ID,:TITLE,:URL,:BODY_COUNT_ALL,:REPLY_COUNT_ALL,:COUNT_ALL,:USER_COUNT_ALL)";
|
||||
|
||||
query.prepare(strQuery.toUtf8());
|
||||
foreach(SPowerCafeCount stIn,list)
|
||||
{
|
||||
query.bindValue(":ID",stIn.m_strCafeID.trimmed().toUtf8());
|
||||
query.bindValue(":TITLE",stIn.m_strTitle.trimmed().toUtf8());
|
||||
query.bindValue(":URL",QString("cafe.naver.com/" + stIn.m_strCafeID.trimmed()).toUtf8());
|
||||
query.bindValue(":BODY_COUNT_ALL",stIn.m_ncBodyAll);
|
||||
query.bindValue(":REPLY_COUNT_ALL",stIn.m_ncReplyAll);
|
||||
query.bindValue(":COUNT_ALL",stIn.m_ncAll);
|
||||
query.bindValue(":USER_COUNT_ALL",stIn.m_mapUser.size());
|
||||
if(query.exec() == false) {InsertLog(query.lastError().text());return;}
|
||||
}
|
||||
|
||||
int nCount = 0;
|
||||
strQuery = "insert into stats_powercaferank (articlecountreal,usercountreal,orderby,company_num,id,title,articlecountall)"
|
||||
" VALUES (0,0,'articlecountall'," + strCompanyNum + ",:ID,:TITLE,:COUNT_ALL)";
|
||||
query.prepare(strQuery.toUtf8());
|
||||
foreach(SPowerCafeCount stIn,list)
|
||||
{
|
||||
if (nCount >= 10) break; nCount++;
|
||||
query.bindValue(":ID",stIn.m_strCafeID.trimmed().toUtf8());
|
||||
query.bindValue(":TITLE",stIn.m_strTitle.trimmed().toUtf8());
|
||||
query.bindValue(":COUNT_ALL",stIn.m_ncAll);
|
||||
if(query.exec() == false) {InsertLog(query.lastError().text());return;}
|
||||
}
|
||||
db.close();
|
||||
InsertLog("PowerCafe Rank Count Send End");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool QSortBody(const SInfluenceCount &stInflunce1, const SInfluenceCount &stInflunce2)
|
||||
{
|
||||
return stInflunce1.m_ncBody > stInflunce2.m_ncBody;
|
||||
@@ -1071,12 +1178,12 @@ bool QSortInfulrence(const SInfluenceCount &stInflunce1, const SInfluenceCount &
|
||||
return stInflunce1.m_dinfulrence > stInflunce2.m_dinfulrence;
|
||||
}
|
||||
|
||||
void Widget::on_count()
|
||||
void Widget::on_influence_count()
|
||||
{
|
||||
QMap <QString,SInfluenceCount> mapCount;
|
||||
foreach (QListWidgetItem *item,m_plw[E_LIST_COMPANY].selectedItems())
|
||||
{
|
||||
InsertLog("Influence Rank Count Make Start " + item->text());
|
||||
InsertLog("Influence Rank Count Make Start " + item->text());
|
||||
QString strCompanyNum = item->data(Qt::UserRole).toString();
|
||||
foreach(SBody stBody, m_mapData.values())
|
||||
{
|
||||
|
||||
@@ -53,6 +53,20 @@ struct SInfluenceCount
|
||||
QString m_strTitle;
|
||||
};
|
||||
|
||||
struct SPowerCafeCount
|
||||
{
|
||||
QString m_strCafeID;
|
||||
QString m_strTitle;
|
||||
int m_ncBodyAll;
|
||||
int m_ncReplyAll;
|
||||
int m_ncAll;
|
||||
int m_ncBodyReal;
|
||||
int m_ncReplyReal;
|
||||
int m_ncAllReal;
|
||||
int m_ncUserReal;
|
||||
QMap <QString,bool> m_mapUser;
|
||||
};
|
||||
|
||||
struct SBuzzyArticle
|
||||
{
|
||||
QMap <QDate,int> m_mapCount;
|
||||
@@ -180,7 +194,8 @@ private slots:
|
||||
void on_send();
|
||||
void on_delete();
|
||||
void on_refresh();
|
||||
void on_count();
|
||||
void on_influence_count();
|
||||
void on_power_cafe_count();
|
||||
void Update();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user