Little fixes and changes

This commit is contained in:
ondra 2020-12-18 09:45:13 +01:00
parent 4283707daf
commit 55b780d34f
3 changed files with 3 additions and 6 deletions

View File

@ -415,7 +415,6 @@ bool ColnodAPI::updateAuthToken() {
emit authTokenUpdated(false);; emit authTokenUpdated(false);;
return ; return ;
} }
qDebug(colnod) << "Auth token updated.";
emit authTokenUpdated(true); emit authTokenUpdated(true);
}); });
} }

View File

@ -36,7 +36,7 @@ std::shared_ptr<Data> DatabaseAPI::downloadData()
{ {
auto updatedQuery = mDbMan->createQuery(); auto updatedQuery = mDbMan->createQuery();
auto deletedQuery = mDbMan->createQuery(); auto deletedQuery = mDbMan->createQuery();
if (!executeQuery(updatedQuery, "SELECT * FROM colnod_token WHERE last_modified > last_update AND deleted = false")) { if (!executeQuery(updatedQuery, "SELECT * FROM colnod_token WHERE (last_modified > last_update OR last_update IS NULL) AND deleted = false ")) {
qWarning(database) << "ERROR during geting new/updated tokens from db."; qWarning(database) << "ERROR during geting new/updated tokens from db.";
return nullptr; return nullptr;
} }
@ -238,7 +238,6 @@ bool DatabaseAPI::deleteItems(const QList<QString> &ids, const QString &tableNam
{ {
auto query = mDbMan->createQuery(); auto query = mDbMan->createQuery();
QString nowString = QDateTime::fromMSecsSinceEpoch(getLastSync()).toString("yyyy-MM-dd hh:mm:ss"); QString nowString = QDateTime::fromMSecsSinceEpoch(getLastSync()).toString("yyyy-MM-dd hh:mm:ss");
nowString = "'" + nowString + "'";
if (tableName == "colnod_subject") { if (tableName == "colnod_subject") {
for (const auto &id : ids) { for (const auto &id : ids) {
query.prepare("DELETE FROM colnod_subject_attribute WHERE subject_id = :id"); query.prepare("DELETE FROM colnod_subject_attribute WHERE subject_id = :id");
@ -254,7 +253,6 @@ bool DatabaseAPI::deleteItems(const QList<QString> &ids, const QString &tableNam
for (const auto &id : ids) { for (const auto &id : ids) {
query.prepare(QString("UPDATE %1 SET deleted = true, last_update = :now, last_modified = :now WHERE id = :id").arg(tableName)); query.prepare(QString("UPDATE %1 SET deleted = true, last_update = :now, last_modified = :now WHERE id = :id").arg(tableName));
// QString tempId = "'" + id + "'";
query.bindValue(":id", id); query.bindValue(":id", id);
query.bindValue(":now", nowString); query.bindValue(":now", nowString);
if (!executeQuery(query)) { if (!executeQuery(query)) {

View File

@ -91,7 +91,7 @@ bool SyncManager::startSynchronization()
return; return;
} }
Timestamp time; Timestamp time;
time.setTimestamp(syncBegin); time.setTimestamp(syncBegin - 75 * 1000);
auto tokensRequest = colnod->getTokensUpdated(time); auto tokensRequest = colnod->getTokensUpdated(time);
@ -228,7 +228,7 @@ void SyncManager::initNewToken(const std::shared_ptr<Token>& token)
Q_ASSERT(database); Q_ASSERT(database);
Q_ASSERT(token); Q_ASSERT(token);
qint16 num = database->getNumOfTokensOfSubject(token->subjectId()); qint16 num = database->getNumOfTokensOfSubject(token->subjectId());
token->setName(database->getSubjectNameByTokenId(token->id()) + "_mobile_" + QString::number(num + 1)); token->setName(database->getSubjectNameByTokenId(token->id()) + "-" + QString::number(num + 1));
token->setDescription("mobile"); token->setDescription("mobile");
token->setTokenData(token->tokenData().toUpper()); token->setTokenData(token->tokenData().toUpper());