private def completeProgressTracking()

in app/com/gu/floodgate/reindex/ProgressTracker.scala [169:196]


  private def completeProgressTracking(
      status: ReindexStatus,
      contentSource: ContentSource,
      runningJob: RunningJob
  ): Unit = {

    def cleanupAndStop(): Unit = {
      nextPollSchedule foreach { _.cancel() } // cancel any schedule that we might have set up
      context.stop(self)
    }

    logger.info(s"Completing progress tracking for job from '${contentSource.id}' with reindex status: ${status}")
    val jobHistory = JobHistory(
      runningJob.contentSourceId,
      runningJob.startTime,
      new DateTime(),
      status,
      runningJob.contentSourceEnvironment,
      runningJob.rangeFrom,
      runningJob.rangeTo,
      Some(runningJob.documentsExpected),
      Some(runningJob.documentsIndexed)
    )
    runningJobService.removeRunningJob(runningJob.contentSourceId, runningJob.contentSourceEnvironment)
    jobHistoryService.createJobHistory(jobHistory)

    cleanupAndStop()
  }