From 9f9f2877218fe2f625eaeb5b647ec092889f0d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Fischer?= Date: Mon, 25 Nov 2019 13:48:17 +0100 Subject: [PATCH] Edit output --- README.md | 10 ++++++++++ doc/possible-checks.md | 2 ++ server-sdk | 2 +- src/colnod/colnodapi.cpp | 8 ++++---- src/colnod/data.h | 12 ++++++++++++ src/colnod/databaseapi.cpp | 14 ++++++++++---- src/colnod/syncmanager.cpp | 16 ++++++++++------ 7 files changed, 49 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f33eb4a..aa3eb4a 100644 --- a/README.md +++ b/README.md @@ -171,3 +171,13 @@ It is possible to chain requests: [see doc](https://support.insomnia.rest/articl ## Possible checks [here](https://gitlab.com/spaceti-app/integrations/acs/colnod-connector/blob/master/doc/possible-checks.md) + +## Bugs and improvments for Colsys +### Bugs +- It is possible to add token with token ID (tokenData) which already exists +- No error message, when request data are invalid in login +### Improvements +- it would be nice to get response messages on calling enpoints + - setToken -> successful edit/insert + - deleteToken -> successful + - diff --git a/doc/possible-checks.md b/doc/possible-checks.md index 4ea4530..29e1e0a 100644 --- a/doc/possible-checks.md +++ b/doc/possible-checks.md @@ -3,3 +3,5 @@ ## Cases: - try to add new virtual token to subject who has no physical card +- insert token with tokenData already exists +- token which has not "mobile" in description can't be pushed/deleted from colnod \ No newline at end of file diff --git a/server-sdk b/server-sdk index 5025a68..eddfc40 160000 --- a/server-sdk +++ b/server-sdk @@ -1 +1 @@ -Subproject commit 5025a68891fc7ffd72300327de7a1a43b6ca80b6 +Subproject commit eddfc401b0282d53ba7289bb5c3ffa41e0287dda diff --git a/src/colnod/colnodapi.cpp b/src/colnod/colnodapi.cpp index 8e464a4..4a6e6d2 100644 --- a/src/colnod/colnodapi.cpp +++ b/src/colnod/colnodapi.cpp @@ -195,10 +195,10 @@ void ColnodAPI::areDataReady() if (++amountData == 4) { qInfo(colnod) << tab << "-> COLNOD DATA:"; - qInfo(colnod) << tab << tab << mData->updatedTokens.size() << "TOKENS WERE MODIFIED"; - qInfo(colnod) << tab << tab << mData->deletedTokens.size() << "TOKENS MARKED FOR DELETION"; - qInfo(colnod) << tab << tab << mData->updatedSubjects.size() << "SUBJECTS WERE MODIFIED"; - qInfo(colnod) << tab << tab << mData->deletedSubjects.size() << "SUBJECTS MARKED FOR DELETION"; + qInfo(colnod) << tab << tab << mData->updatedTokens.size() << "TOKENS WERE ADDED/UPDATED"; + qInfo(colnod) << tab << tab << mData->deletedTokens.size() << "TOKENS DELETED"; + qInfo(colnod) << tab << tab << mData->updatedSubjects.size() << "SUBJECTS WERE ADDED/UPDATED"; + qInfo(colnod) << tab << tab << mData->deletedSubjects.size() << "SUBJECTS DELETED"; qInfo(colnod) << dash; emit downloadDataFinished(mData); diff --git a/src/colnod/data.h b/src/colnod/data.h index 2edc83a..7614c89 100644 --- a/src/colnod/data.h +++ b/src/colnod/data.h @@ -9,6 +9,18 @@ constexpr auto underscore = "___________________________________________________ constexpr auto dash = "------------------------------------------------------------------"; constexpr auto tab = "\t"; + +class Message +{ +public: + static QString massageTemplate(QString action, QString item, QString source, QString itemInfo) + { + return "[" + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + + "] " + action + " " + item + "in " + source + ", " + item + " " + itemInfo + "'"; + } +}; + + class Data { public: diff --git a/src/colnod/databaseapi.cpp b/src/colnod/databaseapi.cpp index 4233d92..ad86550 100644 --- a/src/colnod/databaseapi.cpp +++ b/src/colnod/databaseapi.cpp @@ -36,9 +36,9 @@ void DatabaseAPI::processData(const std::shared_ptr &data) deleteItems(data->deletedSubjects, "colnod_subject"); qInfo(database) << tab << "-> DATA PROCESSED TO DATABASE:"; - qInfo(database) << tab << tab << data->updatedTokens.size() << "TOKENS UPDATED"; + qInfo(database) << tab << tab << data->updatedTokens.size() << "TOKENS ADDED/UPDATED"; qInfo(database) << tab << tab << data->deletedTokens.size() << "TOKENS DELETED"; - qInfo(database) << tab << tab << data->updatedSubjects.size() << "SUBJECTS UPDATED"; + qInfo(database) << tab << tab << data->updatedSubjects.size() << "SUBJECTS ADDED/UPDATED"; qInfo(database) << tab << tab << data->deletedSubjects.size() << "SUBJECTS DELETED"; qInfo(database) << dash; } @@ -56,7 +56,7 @@ std::shared_ptr DatabaseAPI::composeData(const QSqlQuery &updatedQuery, QS } qInfo(database) << tab << "-> DATABASE DATA:"; - qInfo(database) << tab << tab << data->updatedTokens.size() << "TOKENS WERE MODIFIED"; + qInfo(database) << tab << tab << data->updatedTokens.size() << "TOKENS WERE ADDED/UPDATED"; qInfo(database) << tab << tab << data->deletedTokens.size() << "TOKENS MARKED FOR DELETION"; qInfo(database) << dash ; @@ -170,10 +170,16 @@ void DatabaseAPI::deleteItems(const QList &ids, const QString &tableNam auto query = mDbMan->createQuery(); QString nowString = QDateTime::fromMSecsSinceEpoch(getLastSync()).toString("yyyy-MM-dd hh:mm:ss.zzz"); for (const auto &id : ids) { + qInfo(database) << Message::massageTemplate("deleting", tableName.mid(tableName.indexOf("_") + 1, tableName.length() - 1), "database", id); + qInfo(database).noquote() << "[" <executeQuery(query); + qDebug() << query.isActive() << ",is active on update???"; } } @@ -192,7 +198,7 @@ std::shared_ptr DatabaseAPI::getToken(const QString &id) bool DatabaseAPI::isAlreadyDeleted(const QString &id) { auto token = getToken(id); - if (token->lastUpdate() >= token->lastModified()) + if (token->deleted()) return true; return false; diff --git a/src/colnod/syncmanager.cpp b/src/colnod/syncmanager.cpp index d1dafe4..ed47cad 100644 --- a/src/colnod/syncmanager.cpp +++ b/src/colnod/syncmanager.cpp @@ -50,7 +50,7 @@ void SyncManager::run() connect(this, &SyncManager::syncFinished, [=](){ database->setLastSync(syncBegin); - qInfo(syncmanager) << "Update last synchronization time to time of this sync (" + qInfo(syncmanager).noquote() << "Update last synchronization time to time of this sync (" << QDateTime::fromMSecsSinceEpoch(syncBegin).toString("yyyy-MM-dd hh:mm:ss.zzz") << ")"; qInfo(syncmanager) << equals; @@ -70,7 +70,7 @@ void SyncManager::downloadData() qInfo(syncmanager) << equals; qInfo(syncmanager) << "DOWNLOADING DATA -> BEGIN"; qInfo(syncmanager) << dash; - qInfo(syncmanager) << "Modified data since last synchronization (" << mlastSync.toDateString() << "):"; + qInfo(syncmanager).noquote() << "Modified data since last synchronization (" << mlastSync.toDateString() << "):"; qInfo(syncmanager) << dash; connect(colnod.get(), &ColnodAPI::downloadDataFinished, this, &SyncManager::saveColnodData); @@ -116,6 +116,12 @@ void SyncManager::prepareData() for (const auto &id : alreadySynced) colnodDataToProcess->updatedTokens.remove(id); + qInfo(syncmanager) << tab << "-> COLNOD DATA - CHANGES:"; + qInfo(syncmanager) << tab << tab << conflicts.size() << "TOKENS WERE ADDED/UPDATED IN DATABASE TOO"; + qInfo(syncmanager) << tab << tab << alreadySynced.size() << "TOKENS WERE ALREADY SYNCED"; + + + conflicts.clear(); // chech for already deleted ( in previous synced tokens were deleted from colnod, so it come to this sync but we dont want to sync it again @@ -128,9 +134,7 @@ void SyncManager::prepareData() colnodDataToProcess->deletedTokens.removeOne(id); } - qInfo(syncmanager) << tab << "-> COLNOD DATA - CHANGES:"; - qInfo(syncmanager) << tab << tab << conflicts.size() << "TOKENS WERE MODIFIED IN DATABASE"; - qInfo(syncmanager) << tab << tab << alreadySynced.size() << "TOKENS WERE ALREADY SYNCED"; + qInfo(syncmanager) << tab << tab << conflicts.size() << "TOKENS WERE ALREADY DELETED"; qInfo(syncmanager) << dash; conflicts.clear(); @@ -153,7 +157,7 @@ void SyncManager::prepareData() colnodDataToProcess->updatedTokens.remove(id); qInfo(syncmanager) << tab << "-> DATABASE DATA - CHANGES:"; - qInfo(syncmanager) << tab << tab << conflicts.size() << "TOKENS WERE MODIFIED IN COLNOD"; + qInfo(syncmanager) << tab << tab << conflicts.size() << "TOKENS WERE ADDED/UPDATED IN IN COLNOD TOO"; qInfo(syncmanager) << dash; qInfo(syncmanager) << "PREPARING DATA -> FINISHED";