Added Account Age

+ Added the ability to see the account age of registered users. Changes
are both in server and client. The server will now send back the
registration date along with the user data. The client will then use
this to calculate the account age and display it in the user details
window.
This commit is contained in:
Matt Lowe
2015-01-07 22:28:35 +01:00
parent 7476667b69
commit 02043ad4f9
4 changed files with 72 additions and 37 deletions

View File

@@ -8,6 +8,7 @@
#include <QDebug>
#include <QSqlError>
#include <QSqlQuery>
#include <QDateTime>
Servatrice_DatabaseInterface::Servatrice_DatabaseInterface(int _instanceId, Servatrice *_server)
: instanceId(_instanceId),
@@ -283,6 +284,12 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer
const QString realName = query.value(3).toString();
if (!realName.isEmpty())
result.set_real_name(realName.toStdString());
const QDateTime regDate = query.value(7).toDateTime();
if(!regDate.toString(Qt::ISODate).isEmpty()) {
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTime());
result.set_accountage_secs(accountAgeInSeconds);
}
return result;
}
@@ -298,7 +305,7 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b
return result;
QSqlQuery query(sqlDatabase);
query.prepare("select id, name, admin, realname, gender, country, avatar_bmp from " + server->getDbPrefix() + "_users where name = :name and active = 1");
query.prepare("select id, name, admin, realname, gender, country, avatar_bmp, registrationDate from " + server->getDbPrefix() + "_users where name = :name and active = 1");
query.bindValue(":name", name);
if (!execSqlQuery(query))
return result;