날짜별 카운트 추가
git-svn-id: svn://192.168.0.12/source@51 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
@@ -656,9 +656,7 @@ bool Widget::ReloadColumn()
|
||||
|
||||
m_nUrlColumn = m_anData[E_DATA_article_url];
|
||||
m_nDateColumn = m_anData[E_DATA_article_date];
|
||||
m_nOrderColumn = m_anData[E_DATA_article_order];
|
||||
|
||||
m_nDateColumn++;
|
||||
m_nOrderColumn = m_anData[E_DATA_article_order];
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -765,10 +763,37 @@ void Widget::MakeBuzzyAll()
|
||||
m_vecBuzzy.push_back(stBuzzy);
|
||||
}
|
||||
|
||||
QVariant Widget::GetWebData(QString _strTable,QString _strColumn,int _nNum)
|
||||
{
|
||||
QVariant value;
|
||||
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 value;
|
||||
}
|
||||
QSqlQuery query("select " + _strColumn + " FROM " + _strTable + " where num = " + QString::number(_nNum));
|
||||
qDebug() << "select " + _strColumn + " FROM " + _strTable + " where num = " + QString::number(_nNum);
|
||||
if (query.next() == true)
|
||||
value = query.value(0);
|
||||
db.close();
|
||||
return value;
|
||||
}
|
||||
|
||||
void Widget::MakeBuzzy(int _nCategory)
|
||||
{
|
||||
SBuzzy stBuzzy;
|
||||
stBuzzy.m_nCategory = _nCategory;
|
||||
QVariant value = GetWebData("category","statsColumnNum",_nCategory);
|
||||
if (value.isNull())
|
||||
{
|
||||
InsertLog("Make Buzzy Error : statsColumnNum is null ...");
|
||||
return;
|
||||
}
|
||||
stBuzzy.m_nCategory = value.toInt();
|
||||
if (stBuzzy.m_nCategory == -1) return;
|
||||
QMap <QString,bool> map;
|
||||
if (m_bDataFlag[E_ARTICLE_BODY] == true)
|
||||
{
|
||||
@@ -891,6 +916,7 @@ void Widget::DataPut(QString _strCompanyNum)
|
||||
|
||||
QSqlQuery query;
|
||||
QString strQuery;
|
||||
|
||||
strQuery = "delete from body_" + _strCompanyNum;
|
||||
if(query.exec(strQuery.toUtf8()) == false) {InsertLog(query.lastError().text());return;}
|
||||
|
||||
@@ -900,6 +926,9 @@ void Widget::DataPut(QString _strCompanyNum)
|
||||
strQuery = "delete from body_category_map_" + _strCompanyNum;
|
||||
if(query.exec(strQuery.toUtf8()) == false) {InsertLog(query.lastError().text());return;}
|
||||
|
||||
strQuery = "delete from stats_articlebuzzbyday where company_num = " + _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 strMapQuery = QString("insert into body_category_map_" + _strCompanyNum + " (num,body_num,category_num,realin) VALUES (:NUM,:BODY_NUM,:CATEGORY_NUM,:REALIN)").toUtf8();
|
||||
@@ -982,6 +1011,48 @@ void Widget::DataPut(QString _strCompanyNum)
|
||||
InsertLog(query.lastError().text());return;
|
||||
}
|
||||
}
|
||||
|
||||
QDate date = QDate::currentDate().addDays(-60);
|
||||
QString astrOrderBy[D_ARTICLE_MAX] = {"body","reply","all"};
|
||||
while(date <= QDate::currentDate())
|
||||
{
|
||||
QVector <SBuzzyCount> vecCount;
|
||||
foreach(SBuzzy stBuzzy,m_vecBuzzy)
|
||||
{
|
||||
SBuzzyCount stCount;
|
||||
stCount.m_nCategory = stBuzzy.m_nCategory;
|
||||
memset(&stCount.m_anCount,0,sizeof(int)*D_ARTICLE_MAX);
|
||||
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))
|
||||
stCount.m_anCount[1] = stBuzzy.m_astArticle[E_ARTICLE_REPLY].m_mapCount[date];
|
||||
stCount.m_anCount[2] = stCount.m_anCount[0] + stCount.m_anCount[1];
|
||||
vecCount.push_back(stCount);
|
||||
}
|
||||
for (int i = 0; i < D_ARTICLE_MAX ; i++)
|
||||
{
|
||||
strQuery = "insert stats_articlebuzzbyday set ";
|
||||
foreach(SBuzzyCount stCount,vecCount)
|
||||
{
|
||||
strQuery += "category_";
|
||||
strQuery += QString::number(stCount.m_nCategory);
|
||||
strQuery += " = ";
|
||||
strQuery += QString::number(stCount.m_anCount[i]);
|
||||
strQuery += ",";
|
||||
}
|
||||
strQuery += "date = '";
|
||||
strQuery += date.toString("yyyy-MM-dd");
|
||||
strQuery += "', orderby = '";
|
||||
strQuery += astrOrderBy[i];
|
||||
strQuery += "',company_num = ";
|
||||
strQuery += _strCompanyNum;
|
||||
if (query.exec(strQuery.toUtf8())==false)
|
||||
{
|
||||
InsertLog(query.lastError().text());
|
||||
}
|
||||
}
|
||||
date = date.addDays(1);
|
||||
}
|
||||
db.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,14 @@ struct SBuzzyArticle
|
||||
QMap <QDate,int> m_mapCount;
|
||||
};
|
||||
|
||||
#define D_ARTICLE_MAX 3
|
||||
|
||||
struct SBuzzyCount
|
||||
{
|
||||
int m_nCategory;
|
||||
int m_anCount[D_ARTICLE_MAX];
|
||||
};
|
||||
|
||||
class Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -163,6 +171,7 @@ private:
|
||||
QString MakeInfluencerrankQuery(SInfluenceCount &_stIn,QString _strOrder,QString _strCompanyNum);
|
||||
void MakeBuzzyAll();
|
||||
void MakeBuzzy(int _nCategory);
|
||||
QVariant GetWebData(QString _strTable,QString _strColumn,int _nNum);
|
||||
|
||||
private slots:
|
||||
void CompanyItemChanged(QListWidgetItem*,QListWidgetItem* _prev = 0);
|
||||
|
||||
Reference in New Issue
Block a user