def flush
      reports_to_flush = run_and_log_time('Getting the reports from Redis') do
        reports
      end

      run_and_log_time('Reporting to 3scale') { report(reports_to_flush) }

      # Ideally, we would like to ensure that once we start checking
      # authorizations, they have taken into account the reports that we just
      # performed. However, in 3scale, reports are asynchronous and the current
      # API does not provide a way to know whether a report has already been
      # processed.
      # For now, let's just wait a few seconds. This will greatly mitigate the
      # problem.
      run_and_log_time('Giving reports some time to be processed') do
        sleep(WAIT_TIME_REPORT_AUTH)
      end

      auths = run_and_log_time('Getting the auths from 3scale') do
        authorizations(reports_to_flush)
      end

      run_and_log_time('Renewing the auths in Redis') { renew(auths) }
    end
def flush
      reports_to_flush = run_and_log_time('Getting the reports from Redis') do
        reports
      end

      run_and_log_time('Reporting to 3scale') { report(reports_to_flush) }

      # Ideally, we would like to ensure that once we start checking
      # authorizations, they have taken into account the reports that we just
      # performed. However, in 3scale, reports are asynchronous and the current
      # API does not provide a way to know whether a report has already been
      # processed.
      # For now, let's just wait a few seconds. This will greatly mitigate the
      # problem.
      run_and_log_time('Giving reports some time to be processed') do
        sleep(WAIT_TIME_REPORT_AUTH)
      end

      auths = run_and_log_time('Getting the auths from 3scale') do
        authorizations(reports_to_flush)
      end

      run_and_log_time('Renewing the auths in Redis') { renew(auths) }
    end
TODO: decide if we want to renew the authorizations every time.