| 370 | } |
| 371 | |
| 372 | void AutosaveWindow::processAutomaticSavepoints() |
| 373 | { |
| 374 | if (!_autosaveEnabled) { |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | if (!_lastSessionId.has_value() || _lastSessionId.value() != _simulationFacade->getSessionId()) { |
| 379 | _lastAutosaveTimepoint = std::chrono::steady_clock::now(); |
| 380 | _lastSessionId = _simulationFacade->getSessionId(); |
| 381 | _peakDeserializedSimulation->reset(); |
| 382 | } |
| 383 | |
| 384 | auto minSinceLastAutosave = std::chrono::duration_cast<std::chrono::minutes>(std::chrono::steady_clock::now() - _lastAutosaveTimepoint).count(); |
| 385 | if (minSinceLastAutosave >= _autosaveInterval && _savepointTable.has_value()) { |
| 386 | onCreateSavepoint(_catchPeaks != CatchPeaks_None); |
| 387 | _lastAutosaveTimepoint = std::chrono::steady_clock::now(); |
| 388 | _lastPeakTimepoint = std::chrono::steady_clock::now(); |
| 389 | } |
| 390 | |
| 391 | if (_catchPeaks != CatchPeaks_None) { |
| 392 | auto minSinceLastCatchPeak = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - _lastPeakTimepoint).count(); |
| 393 | if (minSinceLastCatchPeak >= PeakDetectionInterval) { |
| 394 | _peakProcessor->executeTask( |
| 395 | [&](auto const& senderId) { |
| 396 | return _persisterFacade->scheduleGetPeakSimulation( |
| 397 | SenderInfo{.senderId = senderId, .wishResultData = false, .wishErrorInfo = true}, |
| 398 | GetPeakSimulationRequestData{ |
| 399 | .peakDeserializedSimulation = _peakDeserializedSimulation, |
| 400 | .zoom = Viewport::get().getZoomFactor(), |
| 401 | .center = Viewport::get().getCenterInWorldPos()}); |
| 402 | }, |
| 403 | [&](auto const& requestId) {}, |
| 404 | [](auto const& errors) { GenericMessageDialog::get().information("Error", errors); }); |
| 405 | _lastPeakTimepoint = std::chrono::steady_clock::now(); |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | void AutosaveWindow::scheduleDeleteNonPersistentSavepoint(std::vector<SavepointEntry> const& entries) |
| 411 | { |
nothing calls this directly
no test coverage detected