mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 10:50:38 +02:00
delete useless stuff
This commit is contained in:
parent
a19126588b
commit
fe0954edf1
@ -188,7 +188,7 @@ std::shared_ptr<serversdk::Request> ColnodAPI::setTokens(const QHash<QString, st
|
||||
connect(request.get(), &serversdk::Request::finished, [=](){
|
||||
if (!checkRequest(request)) {
|
||||
qCritical(colnod) << "ERROR during calling /TokenManager/setTokens, request unsuccessful. EXIT";
|
||||
emit error();
|
||||
emit error(); // TODO: retyrn nullptr and check here
|
||||
}
|
||||
if (checkResponse(request->responseData())) {
|
||||
emit partOfDataProcessFinished();
|
||||
@ -210,7 +210,7 @@ std::shared_ptr<serversdk::Request> ColnodAPI::deleteTokens(const QList<QString>
|
||||
connect(request.get(), &serversdk::Request::finished, [=](){
|
||||
if (!checkRequest(request)) {
|
||||
qCritical(colnod) << "ERROR during calling /TokenManager/deleteTokens, request unsuccessful. EXIT";
|
||||
emit error();
|
||||
emit error(); // TODO: return nullptr and check it
|
||||
}
|
||||
if (checkResponse(request->responseData())) {
|
||||
emit partOfDataProcessFinished();
|
||||
@ -250,17 +250,6 @@ void ColnodAPI::setPassword(const QString &password)
|
||||
mPassword = password;
|
||||
}
|
||||
|
||||
qint64 ColnodAPI::lastSync() const
|
||||
{
|
||||
return mLastSync.timestamp();
|
||||
}
|
||||
|
||||
void ColnodAPI::setlastSync(const qint64 &lastSync)
|
||||
{
|
||||
mLastSync.setTimestamp(lastSync);
|
||||
}
|
||||
|
||||
|
||||
QString ColnodAPI::userName() const
|
||||
{
|
||||
return mUserName;
|
||||
@ -322,11 +311,6 @@ void ColnodAPI::saveDeletedSubjects(const std::shared_ptr<Data>& data, const QBy
|
||||
}
|
||||
}
|
||||
|
||||
void ColnodAPI::newData()
|
||||
{
|
||||
mData = std::make_shared<Data>();
|
||||
}
|
||||
|
||||
bool ColnodAPI::checkResponse(const QByteArray &responseData)
|
||||
{
|
||||
QJsonDocument doc = QJsonDocument::fromJson(responseData);
|
||||
|
||||
@ -46,10 +46,8 @@ public:
|
||||
void downloadData(const qint64 &time);
|
||||
void processData(const std::shared_ptr<Data> &data);
|
||||
|
||||
// New approach
|
||||
std::shared_ptr<serversdk::Request> requestLogin();
|
||||
|
||||
|
||||
std::shared_ptr<serversdk::Request> getTokensUpdated(const Timestamp &time);
|
||||
std::shared_ptr<serversdk::Request> getTokensDeleted(const Timestamp &time);
|
||||
std::shared_ptr<serversdk::Request> getSubjectsUpdated(const Timestamp &time);
|
||||
@ -63,8 +61,6 @@ public:
|
||||
void setUserName(const QString &userName);
|
||||
QString password() const;
|
||||
void setPassword(const QString &password);
|
||||
qint64 lastSync() const;
|
||||
void setlastSync(const qint64 &lastSync);
|
||||
|
||||
bool isValid();
|
||||
|
||||
@ -78,11 +74,8 @@ private:
|
||||
void saveDeletedTokens(const std::shared_ptr<Data>& data, const QByteArray &responseData);
|
||||
void saveDeletedSubjects(const std::shared_ptr<Data>& data, const QByteArray &responseData);
|
||||
|
||||
void newData();
|
||||
|
||||
bool checkResponse(const QByteArray &responseData);
|
||||
|
||||
QByteArray getTimestampJson(const qint64 &time);
|
||||
std::shared_ptr<serversdk::Request> composeRequest(const QString &endpoint, const QByteArray &data);
|
||||
|
||||
bool checkRequest(const std::shared_ptr<serversdk::Request> &request);
|
||||
@ -105,8 +98,6 @@ private:
|
||||
bool mDryMode = false;
|
||||
bool mValid = true;
|
||||
|
||||
std::shared_ptr<Data> mData;
|
||||
|
||||
QString authToken;
|
||||
qint16 amountData = 0;
|
||||
qint16 amountProccessesFinished = 0;
|
||||
|
||||
@ -118,24 +118,6 @@ void DatabaseAPI::setLastSync(qint64 timestamp)
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseAPI::reupdateUpdated(const QHash<QString, std::shared_ptr<Token>> &tokens)
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
for (const auto &token : tokens){
|
||||
query.prepare("UPDATE colnod_token SET last_update = :last_update WHERE id = :id");
|
||||
query.bindValue(":last_update", token->lastUpdate());
|
||||
query.bindValue(":id", token->id());
|
||||
if (!executeQuery(query)) {
|
||||
qWarning(database) << "ERROR during updating last update of token:" << token->name() << ", it will be synced from Colnod to db in next sync. Last modified will be invalid";
|
||||
}
|
||||
}
|
||||
|
||||
qInfo(database) << equals;
|
||||
qInfo(database) << "Synchronize last update in database with colnod";
|
||||
qInfo(database) << equals;
|
||||
}
|
||||
|
||||
|
||||
void DatabaseAPI::reupdateDeleted(const QList<QString>& ids)
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
@ -164,26 +146,6 @@ qint64 DatabaseAPI::getNow()
|
||||
return query.value(0).toLongLong();
|
||||
}
|
||||
|
||||
void DatabaseAPI::initNewTokens()
|
||||
{
|
||||
auto query = mDbMan->createQuery();
|
||||
if (!executeQuery(query, "SELECT * FROM colnod_token WHERE name IS NULL")) {
|
||||
qWarning(database) << "ERROR during getting uninitialized tokens";
|
||||
}
|
||||
QHash<QString, std::shared_ptr<Token>> tokensToInit;
|
||||
auto list = utils->tableFromQuery<Token>(query);
|
||||
for (const auto &token : list) {
|
||||
qint16 num = getNumOfTokensOfSubject(token->subjectId());
|
||||
token->setName(getSubjectNameByTokenId(token->id()) + "_mobile_" + QString::number(num + 1));
|
||||
token->setDescription("mobile");
|
||||
token->setTokenData(token->tokenData().toUpper());
|
||||
tokensToInit.insert(token->id(), token);
|
||||
|
||||
qInfo(database).noquote() << Message::massageTemplate("Inicializing new", "token", "database", token->name());
|
||||
}
|
||||
uploadTokens(tokensToInit);
|
||||
}
|
||||
|
||||
bool DatabaseAPI::uploadTokens(const QHash<QString, std::shared_ptr<Token>> &tokens, const QSet<QString> &filters)
|
||||
{
|
||||
// TODO: first check if OK, then message
|
||||
|
||||
@ -31,11 +31,9 @@ public:
|
||||
bool processData(const std::shared_ptr<Data> &data);
|
||||
qint64 getLastSync();
|
||||
void setLastSync(qint64 timestamp);
|
||||
void reupdateUpdated(const QHash<QString, std::shared_ptr<Token> > &tokens);
|
||||
void reupdateDeleted(const QList<QString>& ids);
|
||||
qint64 getNow();
|
||||
|
||||
void initNewTokens();
|
||||
|
||||
// process data
|
||||
bool uploadTokens(const QHash<QString, std::shared_ptr<Token> > &tokens, const QSet<QString> &filters = {});
|
||||
@ -54,7 +52,6 @@ public:
|
||||
private:
|
||||
int exists(const QString &id, const QString &tableName);
|
||||
|
||||
QSqlQuery getUpdatedTokens();
|
||||
std::shared_ptr<Data> composeData(const QSqlQuery &updatedQuery, QSqlQuery &deletedQuery);
|
||||
|
||||
signals:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user