mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
Fix eval
This commit is contained in:
parent
14f290b63b
commit
25804911a6
1 changed files with 22 additions and 20 deletions
|
|
@ -607,15 +607,6 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer
|
||||||
|
|
||||||
result.set_user_level(userLevel);
|
result.set_user_level(userLevel);
|
||||||
|
|
||||||
const auto &pawn_left_override = query->value(10).toString();
|
|
||||||
const auto &pawn_right_override = query->value(11).toString();
|
|
||||||
if (!pawn_left_override.isEmpty()) {
|
|
||||||
result.mutable_pawn_colors()->set_left_side(pawn_left_override.toStdString());
|
|
||||||
}
|
|
||||||
if (!pawn_right_override.isEmpty()) {
|
|
||||||
result.mutable_pawn_colors()->set_right_side(pawn_right_override.toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString country = query->value(3).toString();
|
const QString country = query->value(3).toString();
|
||||||
if (!country.isEmpty())
|
if (!country.isEmpty())
|
||||||
result.set_country(country.toStdString());
|
result.set_country(country.toStdString());
|
||||||
|
|
@ -624,27 +615,36 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer
|
||||||
if (!privlevel.isEmpty())
|
if (!privlevel.isEmpty())
|
||||||
result.set_privlevel(privlevel.toStdString());
|
result.set_privlevel(privlevel.toStdString());
|
||||||
|
|
||||||
|
const auto &pawn_left_override = query->value(5).toString();
|
||||||
|
const auto &pawn_right_override = query->value(6).toString();
|
||||||
|
if (!pawn_left_override.isEmpty()) {
|
||||||
|
result.mutable_pawn_colors()->set_left_side(pawn_left_override.toStdString());
|
||||||
|
}
|
||||||
|
if (!pawn_right_override.isEmpty()) {
|
||||||
|
result.mutable_pawn_colors()->set_right_side(pawn_right_override.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
if (complete) {
|
if (complete) {
|
||||||
const QString realName = query->value(5).toString();
|
const QString realName = query->value(7).toString();
|
||||||
if (!realName.isEmpty())
|
if (!realName.isEmpty())
|
||||||
result.set_real_name(realName.toStdString());
|
result.set_real_name(realName.toStdString());
|
||||||
|
|
||||||
const QByteArray avatarBmp = query->value(6).toByteArray();
|
const QByteArray avatarBmp = query->value(8).toByteArray();
|
||||||
if (avatarBmp.size())
|
if (avatarBmp.size())
|
||||||
result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size());
|
result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size());
|
||||||
|
|
||||||
const QDateTime regDate = query->value(7).toDateTime();
|
const QDateTime regDate = query->value(9).toDateTime();
|
||||||
if (!regDate.toString(Qt::ISODate).isEmpty()) {
|
if (!regDate.toString(Qt::ISODate).isEmpty()) {
|
||||||
// the registration date is in utc
|
// the registration date is in utc
|
||||||
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTimeUtc());
|
qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTimeUtc());
|
||||||
result.set_accountage_secs(accountAgeInSeconds);
|
result.set_accountage_secs(accountAgeInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString email = query->value(8).toString();
|
const QString email = query->value(10).toString();
|
||||||
if (!email.isEmpty())
|
if (!email.isEmpty())
|
||||||
result.set_email(email.toStdString());
|
result.set_email(email.toStdString());
|
||||||
|
|
||||||
const QString clientid = query->value(9).toString();
|
const QString clientid = query->value(11).toString();
|
||||||
if (!clientid.isEmpty())
|
if (!clientid.isEmpty())
|
||||||
result.set_clientid(clientid.toStdString());
|
result.set_clientid(clientid.toStdString());
|
||||||
}
|
}
|
||||||
|
|
@ -661,10 +661,10 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b
|
||||||
if (!checkSql())
|
if (!checkSql())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
QSqlQuery *query =
|
QSqlQuery *query = prepareQuery("select id, name, admin, country, privlevel, leftPawnColorOverride, "
|
||||||
prepareQuery("select id, name, admin, country, privlevel, realname, avatar_bmp, registrationDate, "
|
"rightPawnColorOverride, realname, avatar_bmp, registrationDate, "
|
||||||
"email, clientid, leftPawnColorOverride, rightPawnColorOverride from {prefix}_users where "
|
"email, clientid from {prefix}_users where "
|
||||||
"name = :name and active = 1");
|
"name = :name and active = 1");
|
||||||
query->bindValue(":name", name);
|
query->bindValue(":name", name);
|
||||||
if (!execSqlQuery(query))
|
if (!execSqlQuery(query))
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -761,7 +761,8 @@ QMap<QString, ServerInfo_User> Servatrice_DatabaseInterface::getBuddyList(const
|
||||||
if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) {
|
if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) {
|
||||||
checkSql();
|
checkSql();
|
||||||
|
|
||||||
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a "
|
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel, "
|
||||||
|
"a.leftPawnColorOverride, a.rightPawnColorOverride from {prefix}_users a "
|
||||||
"left join {prefix}_buddylist b on a.id = b.id_user2 left join {prefix}_users "
|
"left join {prefix}_buddylist b on a.id = b.id_user2 left join {prefix}_users "
|
||||||
"c on b.id_user1 = c.id where c.name = :name");
|
"c on b.id_user1 = c.id where c.name = :name");
|
||||||
query->bindValue(":name", name);
|
query->bindValue(":name", name);
|
||||||
|
|
@ -783,7 +784,8 @@ QMap<QString, ServerInfo_User> Servatrice_DatabaseInterface::getIgnoreList(const
|
||||||
if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) {
|
if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) {
|
||||||
checkSql();
|
checkSql();
|
||||||
|
|
||||||
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a "
|
QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel, "
|
||||||
|
"a.leftPawnColorOverride, a.rightPawnColorOverride from {prefix}_users a "
|
||||||
"left join {prefix}_ignorelist b on a.id = b.id_user2 left join {prefix}_users "
|
"left join {prefix}_ignorelist b on a.id = b.id_user2 left join {prefix}_users "
|
||||||
"c on b.id_user1 = c.id where c.name = :name");
|
"c on b.id_user1 = c.id where c.name = :name");
|
||||||
query->bindValue(":name", name);
|
query->bindValue(":name", name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue