Changeset 380:e9921b6fc914

Show
Ignore:
Timestamp:
05/18/2009 11:36:45 PM (3 years ago)
Author:
Dmitry Nezhevenko <dion@…>
Branch:
default
Message:

Introduce some kind of MUC statistic. Currently collector only, however this is subject to change in future.
Currently PostgreSQL only.

Files:
6 modified
1 moved

Legend:

Unmodified
Added
Removed
  • sql/pgsql.sql

    r371 r380  
    7575); 
    7676 
     77DROP TABLE IF EXISTS conference_jidstat CASCADE; 
     78CREATE TABLE conference_jidstat ( 
     79  id SERIAL, 
     80  jid_id int NOT NULL, 
     81 
     82  time_online int NOT NULL default 0,  
     83 
     84  lastaction int NOT NULL default '0', 
     85  lastreason varchar(200) NULL, 
     86 
     87  msg_count int NOT NULL default 0, 
     88  msg_chars int NOT NULL default 0, 
     89  msg_words int NOT NULL default 0, 
     90  msg_sentences int NOT NULL default 0, 
     91  msg_me int NOT NULL default 0, 
     92  msg_reply int NOT NULL default 0, 
     93  msg_subject int NOT NULL default 0, 
     94 
     95  cnt_join int NOT NULL default 0, 
     96  cnt_leave int NOT NULL default 0, 
     97  cnt_presence int NOT NULL default 0, 
     98  cnt_nickchange int NOT NULL default 0, 
     99  cnt_visitor int NOT NULL default 0, 
     100  cnt_participant int NOT NULL default 0, 
     101  cnt_moderator int NOT NULL default 0, 
     102  cnt_noaffiliation int NOT NULL default 0, 
     103  cnt_member int NOT NULL default 0, 
     104  cnt_administrator int NOT NULL default 0, 
     105  cnt_owner int NOT NULL default 0, 
     106  cnt_kick int NOT NULL default 0, 
     107  cnt_ban int NOT NULL default 0, 
     108  
     109  ver_name varchar(50) NULL, 
     110  ver_version varchar(50) NULL, 
     111  ver_os varchar(200) NULL, 
     112 
     113  PRIMARY KEY(id), 
     114  FOREIGN KEY(jid_id) REFERENCES conference_jids(id) ON DELETE CASCADE, 
     115  UNIQUE(jid_id) 
     116); 
     117 
    77118DROP TABLE IF EXISTS webstatus CASCADE; 
    78119CREATE TABLE webstatus ( 
     
    137178); 
    138179 
    139 INSERT INTO version (name, value) VALUES ('dbversion', 352); 
     180INSERT INTO version (name, value) VALUES ('dbversion', 380); 
  • sql/update/dbupdate.sh

    r352 r380  
    88QUERYCMD="" 
    99INLINE_SUFFIX="" 
     10 
     11if [ "$DBTYPE" = "mysql" ]; then 
     12        echo "MySQL support is currently out of date" 
     13        exit 1 
     14fi 
    1015 
    1116if [ -f "dbupdate.cfg" ]; then 
  • sql/update/pgsql/00380.sql

    r379 r380  
    1515  msg_me int NOT NULL default 0, 
    1616  msg_reply int NOT NULL default 0, 
     17  msg_subject int NOT NULL default 0, 
    1718 
    1819  cnt_join int NOT NULL default 0, 
     
    3031  cnt_ban int NOT NULL default 0, 
    3132   
    32   version varchar(200) NULL, 
     33  ver_name varchar(50) NULL, 
     34  ver_version varchar(50) NULL, 
     35  ver_os varchar(200) NULL, 
    3336 
    3437  PRIMARY KEY(id), 
  • src/base/dbversion.h

    r353 r380  
    2121#define DBVERSION_H 
    2222 
    23 #define GLUXI_DB_VERSION 352 
     23#define GLUXI_DB_VERSION 380 
    2424 
    2525#endif 
  • src/plugins/muc/jidstat.cpp

    r379 r380  
    161161} 
    162162 
    163 void JidStat::setVersion(const QString& v) 
    164 { 
    165         if (id_ <= 0) 
    166                 return; 
    167  
    168         QSqlQuery q = DataStorage::instance()->prepareQuery( 
    169                         "UPDATE conference_jidstat SET version=? WHERE id=?" 
    170         ); 
    171         q.addBindValue(v); 
     163void JidStat::setVersion(const QString& name, const QString& version, const QString& os) 
     164{ 
     165        if (id_ <= 0) 
     166                return; 
     167 
     168        QSqlQuery q = DataStorage::instance()->prepareQuery( 
     169                        "UPDATE conference_jidstat SET ver_name=?, ver_version=?,ver_os=? WHERE id=?" 
     170        ); 
     171        q.addBindValue(name); 
     172        q.addBindValue(version); 
     173        q.addBindValue(os); 
    172174        q.addBindValue(id_); 
    173175        if (!q.exec()) 
     
    268270} 
    269271 
     272void JidStat::statSubject(const QString& subject) 
     273{ 
     274        Q_UNUSED(subject); 
     275        if (id_ <= 0) 
     276                return; 
     277 
     278        QSqlQuery q = DataStorage::instance()->prepareQuery( 
     279                "UPDATE conference_jidstat SET msg_subject = msg_subject + 1 WHERE id=?"); 
     280        q.addBindValue(id_); 
     281        if (!q.exec()) 
     282        { 
     283                qDebug() << "ERROR: Unable to stat subject: " << q.lastError().text(); 
     284        } 
     285} 
  • src/plugins/muc/jidstat.h

    r379 r380  
    5353        void commit(); 
    5454        void setLastAction(ActionType type, const QString& reason); 
    55         void setVersion(const QString& version); 
     55        void setVersion(const QString& name, const QString& version, const QString& os); 
    5656        void updateOnlineTime(); 
    5757        void statMessage(const QString& msg); 
    5858        void statReply(); 
     59        void statSubject(const QString& subject); 
    5960private: 
    6061        int id_; 
  • src/plugins/muc/mucplugin.cpp

    r379 r380  
    536536        JidStat *stat = nick->jidStat(); 
    537537        if (stat) 
    538                 stat->statMessage(msgBody); 
     538        { 
     539                if (!msgBody.isEmpty()) 
     540                        stat->statMessage(msgBody); 
     541                QString subject = QString::fromStdString(s->subject()); 
     542                if (!subject.isEmpty()) 
     543                        stat->statSubject(subject); 
     544        } 
    539545 
    540546        if (msgBody.contains(':')) 
     
    12371243        if (stat) 
    12381244        { 
    1239                 stat->setVersion(QString("%1 %2 // %3").arg(nick->versionName(), 
    1240                                 nick->versionClient(), nick->versionOs())); 
     1245                stat->setVersion(nick->versionName(), nick->versionClient(), 
     1246                                nick->versionOs()); 
    12411247        } 
    12421248