fix number of inserted articles when some article does not meet constraints
This commit is contained in:
parent
b76ce364c2
commit
9934786c8c
4 changed files with 21 additions and 11 deletions
|
@ -26,7 +26,7 @@
|
|||
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="4.1.2" date="2022-02-02"/>
|
||||
<release version="4.1.2" date="2022-02-03"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
|
|
@ -242,6 +242,7 @@ bool DatabaseQueries::createLabel(const QSqlDatabase& db, Label* label, int acco
|
|||
q.bindValue(QSL(":color"), label->color().name());
|
||||
q.bindValue(QSL(":custom_id"), label->customId());
|
||||
q.bindValue(QSL(":account_id"), account_id);
|
||||
|
||||
auto res = q.exec();
|
||||
|
||||
if (res && q.lastInsertId().isValid()) {
|
||||
|
@ -1368,6 +1369,14 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
<< "Message"
|
||||
<< QUOTE_W_SPACE(msg->m_customId)
|
||||
<< "will not be inserted to DB because it does not meet DB constraints.";
|
||||
|
||||
// Message is not inserted to DB at last,
|
||||
// fix numbers.
|
||||
if (!msg->m_isRead) {
|
||||
updated_messages.first--;
|
||||
}
|
||||
|
||||
updated_messages.second--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1398,7 +1407,6 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
if (bulk_error.isValid()) {
|
||||
QString txt = bulk_error.text() + bulk_error.databaseText() + bulk_error.driverText();
|
||||
|
||||
//IOFactory::writeFile("aa.sql", final_bulk.toUtf8());
|
||||
qCriticalNN << LOGSEC_DB
|
||||
<< "Failed bulk insert of articles:"
|
||||
<< QUOTE_W_SPACE_DOT(txt);
|
||||
|
@ -1761,7 +1769,7 @@ bool DatabaseQueries::purgeLabelsAndLabelAssignments(const QSqlDatabase& db, int
|
|||
return succ;
|
||||
}
|
||||
|
||||
bool DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id) {
|
||||
void DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id) {
|
||||
// Iterate all children.
|
||||
auto str = tree_root->getSubTree();
|
||||
|
||||
|
@ -1779,14 +1787,10 @@ bool DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_ro
|
|||
for (RootItem* lbl : qAsConst(ch)) {
|
||||
Label* label = lbl->toLabel();
|
||||
|
||||
if (!createLabel(db, label, account_id)) {
|
||||
return false;
|
||||
createLabel(db, label, account_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList DatabaseQueries::customIdsOfMessagesFromAccount(const QSqlDatabase& db, int account_id, bool* ok) {
|
||||
|
|
|
@ -121,7 +121,7 @@ class DatabaseQueries {
|
|||
static bool cleanImportantMessages(const QSqlDatabase& db, bool clean_read_only, int account_id);
|
||||
static bool cleanUnreadMessages(const QSqlDatabase& db, int account_id);
|
||||
static bool cleanFeeds(const QSqlDatabase& db, const QStringList& ids, bool clean_read_only, int account_id);
|
||||
static bool storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id);
|
||||
static void storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id);
|
||||
static void createOverwriteFeed(const QSqlDatabase& db, Feed* feed, int account_id, int parent_id);
|
||||
static void createOverwriteCategory(const QSqlDatabase& db, Category* category, int account_id, int parent_id);
|
||||
static bool deleteFeed(const QSqlDatabase& db, int feed_custom_id, int account_id);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "database/databasefactory.h"
|
||||
#include "database/databasequeries.h"
|
||||
#include "exceptions/applicationexception.h"
|
||||
#include "gui/dialogs/formaddeditlabel.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
|
@ -61,10 +62,15 @@ void LabelsNode::createLabel() {
|
|||
if (new_lbl != nullptr) {
|
||||
QSqlDatabase db = qApp->database()->driver()->connection(metaObject()->className());
|
||||
|
||||
try {
|
||||
DatabaseQueries::createLabel(db, new_lbl, getParentServiceRoot()->accountId());
|
||||
|
||||
getParentServiceRoot()->requestItemReassignment(new_lbl, this);
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
new_lbl->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||
|
|
Loading…
Add table
Reference in a new issue