mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 10:50:38 +02:00
Edit output
This commit is contained in:
parent
e52c293a41
commit
9f9f287721
10
README.md
10
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
|
||||
-
|
||||
|
||||
@ -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
|
||||
@ -1 +1 @@
|
||||
Subproject commit 5025a68891fc7ffd72300327de7a1a43b6ca80b6
|
||||
Subproject commit eddfc401b0282d53ba7289bb5c3ffa41e0287dda
|
||||
@ -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);
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -36,9 +36,9 @@ void DatabaseAPI::processData(const std::shared_ptr<Data> &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<Data> 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<QString> &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() << "[" <<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") << "]"
|
||||
<< "deleting" << tableName.mid(tableName.indexOf("_") + 1, tableName.length() - 1)
|
||||
<< ":" << "'" << id << "'";
|
||||
|
||||
query.prepare(QString("UPDATE %1 SET deleted = true, last_update = :now, last_modified = :now WHERE id = :id").arg(tableName));
|
||||
query.bindValue(":id", id);
|
||||
query.bindValue(":now", nowString);
|
||||
mDbMan->executeQuery(query);
|
||||
qDebug() << query.isActive() << ",is active on update???";
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +198,7 @@ std::shared_ptr<Token> 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;
|
||||
|
||||
|
||||
@ -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";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user