summaryrefslogtreecommitdiff
path: root/src/atomchannel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/atomchannel.cpp')
-rw-r--r--src/atomchannel.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/atomchannel.cpp b/src/atomchannel.cpp
index 6982e8b..6a7c87c 100644
--- a/src/atomchannel.cpp
+++ b/src/atomchannel.cpp
@@ -78,10 +78,11 @@ AtomChannel::AtomChannel(QXmlStreamReader *xmlReader)
qDebug() << "exit " << __func__;
}
+// TODO: move to a separate function, code is almost identical in all methods called `getDbId`
int AtomChannel::getDbId()
{
- if (dbId != rsshit::db::IdNotFound)
- return dbId;
+ if (id != rsshit::db::IdNotFound)
+ return id;
const auto db = rsshit::db::open();
@@ -93,7 +94,7 @@ int AtomChannel::getDbId()
if (!selectQ.exec()) {
qWarning() << "cannot exec query" << selectQ.lastQuery() << ":"
- << selectQ.lastError().text() << ":" << selectQ.executedQuery();
+ << selectQ.lastError().text();
return rsshit::db::IdNotFound;
}
@@ -118,10 +119,11 @@ int AtomChannel::getDbId()
return result;
}
+// TODO: move to a separate function, code is almost identical in all methods called `createInDb`
int AtomChannel::createInDb()
{
- if (dbId != rsshit::db::IdNotFound)
- return dbId;
+ if (id != rsshit::db::IdNotFound)
+ return id;
const auto db = rsshit::db::open();
@@ -135,7 +137,7 @@ int AtomChannel::createInDb()
if (!insertQ.exec()) {
qWarning() << "cannot exec query" << insertQ.lastQuery() << ":"
- << insertQ.lastError().text() << ":" << insertQ.executedQuery();
+ << insertQ.lastError().text();
return rsshit::db::IdNotFound;
}
@@ -156,16 +158,16 @@ int AtomChannel::getOrInsertDbId()
QList<int> AtomChannel::syncDbItems()
{
- if (dbId == rsshit::db::IdNotFound)
- dbId = getOrInsertDbId();
+ if (id == rsshit::db::IdNotFound)
+ id = getOrInsertDbId();
- if (dbId == rsshit::db::IdNotFound)
+ if (id == rsshit::db::IdNotFound)
return {};
QList<int> result;
for (auto &item : items) {
- auto id = item.getOrInsertDbId(this->dbId);
+ auto id = item.getOrInsertDbId(this->id);
if (id != rsshit::db::IdNotFound)
result << id;