From: APTX Date: Sun, 26 May 2013 00:20:00 +0000 (+0200) Subject: Add clearPendingRequestDataErrors X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=810ea3bb9bd9c8f5ef470b80a1c95e9084119f2c;p=localmylist.git Add clearPendingRequestDataErrors --- diff --git a/localmylist-management/mainwindow.cpp b/localmylist-management/mainwindow.cpp index 4aaaaed..294e0a5 100644 --- a/localmylist-management/mainwindow.cpp +++ b/localmylist-management/mainwindow.cpp @@ -269,6 +269,7 @@ void MainWindow::on_actionClearAnimeTitleData_triggered() void MainWindow::on_actionClearFailedRequests_triggered() { LocalMyList::instance()->database()->clearPendingRequestConnectionErrors(); + LocalMyList::instance()->database()->clearPendingRequestDataErrors(); LocalMyList::instance()->database()->clearFailedPendingMyListUpdateRequests(); } diff --git a/localmylist/database.cpp b/localmylist/database.cpp index 6e9f434..f353c02 100644 --- a/localmylist/database.cpp +++ b/localmylist/database.cpp @@ -1390,6 +1390,38 @@ bool Database::clearPendingRequestConnectionErrors(int minutes) return exec(q); } +bool Database::clearPendingRequestDataErrors() +{ + // TODO make this configurable? + const int steps[] = {1, 2, 4, 8, 24, 48, 48, 48, 48}; + + QSqlQuery &q = prepare( + "UPDATE pending_request " + " SET start = NULL, failed = NULL, " + " connection_error_count = 0, " + " data_error_count = data_error_count + 1 " + " WHERE failed IS NOT NULL " + " AND data_error_count = :dataErrorCount " + " AND age(current_timestamp, failed) > :interval"); + + RaiiTransaction t(this); + + int i = 1; + for (const auto &step : steps) + { + q.bindValue(":dataErrorCount", i); + q.bindValue(":interval", QString::number(step) + " hours"); + + if (!exec(q)) + return false; + + ++i; + } + t.commit(); + + return true; +} + bool Database::clearFailedPendingMyListUpdateRequests(int minutes) { QSqlQuery &q = prepare( diff --git a/localmylist/database.h b/localmylist/database.h index 4d3585f..5a7d251 100644 --- a/localmylist/database.h +++ b/localmylist/database.h @@ -117,7 +117,10 @@ public slots: bool clearFileRenames(); bool clearFailedFileRenames(); + // TODO these are named wrong bool clearPendingRequestConnectionErrors(int minutes = 10); + bool clearPendingRequestDataErrors(); + bool clearFailedPendingMyListUpdateRequests(int minutes = 10); bool truncateTitleData();