void MainWindow::on_actionClearFailedRequests_triggered()
{
LocalMyList::instance()->database()->clearPendingRequestConnectionErrors();
+ LocalMyList::instance()->database()->clearPendingRequestDataErrors();
LocalMyList::instance()->database()->clearFailedPendingMyListUpdateRequests();
}
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(
bool clearFileRenames();
bool clearFailedFileRenames();
+ // TODO these are named wrong
bool clearPendingRequestConnectionErrors(int minutes = 10);
+ bool clearPendingRequestDataErrors();
+
bool clearFailedPendingMyListUpdateRequests(int minutes = 10);
bool truncateTitleData();