mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 20:20:39 +02:00
WIP: prepare data
This commit is contained in:
parent
0dea65a0b6
commit
53015d839a
@ -149,27 +149,53 @@ std::unique_ptr<PreparedData> SyncManager::prepareDataNew(const std::shared_ptr<
|
||||
if (databaseData->updatedTokens.value(colnodToken->id()) < colnodToken) {
|
||||
preperedColnodData->updatedTokens.insert(colnodToken->id(), colnodToken);
|
||||
}
|
||||
|
||||
// updated in db later
|
||||
if (databaseData->updatedTokens.value(colnodToken->id()) > colnodToken) {
|
||||
else {
|
||||
conflicts.append(colnodToken->id());
|
||||
}
|
||||
}
|
||||
|
||||
auto token = database->getToken(colnodToken->id());
|
||||
if ( token )
|
||||
// alredy synced ( tokens are same )
|
||||
if (token == colnodToken)
|
||||
alreadySynced.append(colnodToken->id());
|
||||
}
|
||||
// remove tokens which should be not updated
|
||||
for (const auto &id : conflicts)
|
||||
colnodData->updatedTokens.remove(id);
|
||||
for (const auto &id : alreadySynced)
|
||||
colnodData->updatedTokens.remove(id);
|
||||
|
||||
for (const auto &id : colnodData->deletedTokens) {
|
||||
if (!database->isAlreadyDeleted(id)) {
|
||||
preperedColnodData->deletedTokens.append(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";
|
||||
qInfo(syncmanager) << tab << tab << colnodData->updatedTokens.size() - preperedColnodData->deletedTokens.size() << "TOKENS WERE ALREADY DELETED";
|
||||
qInfo(syncmanager) << dash;
|
||||
|
||||
for (const auto &databaseToken : databaseData->updatedTokens) {
|
||||
if (!colnodData->updatedTokens.contains(databaseToken->id())) {
|
||||
preperedDatabaseData->updatedTokens.insert(databaseToken->id(), databaseToken);
|
||||
}
|
||||
if (databaseToken < colnodData->updatedTokens.value(databaseToken->id()))
|
||||
conflicts.append(databaseToken->id());
|
||||
}
|
||||
else {
|
||||
// restriction cauesed by colnod rest api
|
||||
if (databaseToken->description() != "mobile") {
|
||||
qCritical(syncmanager) << "Token:" << databaseToken->id() << "doesn't have 'mobile' in description, can't be ";
|
||||
conflicts.append(databaseToken->id());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto &id : conflicts)
|
||||
colnodData->updatedTokens.remove(id);
|
||||
|
||||
qInfo(syncmanager) << tab << "-> DATABASE DATA - CHANGES:";
|
||||
qInfo(syncmanager) << tab << tab << conflicts.size() << "TOKENS WERE ADDED/UPDATED IN IN COLNOD TOO";
|
||||
qInfo(syncmanager) << dash;
|
||||
|
||||
qInfo(syncmanager) << "PREPARING DATA -> FINISHED";
|
||||
qInfo(syncmanager) << equals;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user