private IList <INumericRangeBlockContext> GetNumericRangeBlocks(ITaskExecutionContext taskExecutionContext)
        {
            using (var cs = taskExecutionContext.CreateCriticalSection())
            {
                if (cs.TryStart())
                {
                    long startNumber;
                    var  lastBlock    = taskExecutionContext.GetLastNumericRangeBlock(LastBlockOrder.LastCreated);
                    var  maxJourneyId = _travelDataService.GetMaxJourneyId();

                    // if this is the first run then just process the last 1000
                    if (lastBlock == null)
                    {
                        startNumber = maxJourneyId - 1000;
                    }
                    // if there is no new data then just return any old blocks that have failed or died
                    else if (lastBlock.EndNumber == maxJourneyId)
                    {
                        return(taskExecutionContext.GetNumericRangeBlocks(x => x.OnlyOldNumericBlocks()));
                    }
                    // startNumber is the next unprocessed id
                    else
                    {
                        startNumber = lastBlock.EndNumber + 1;
                    }

                    int maxBlockSize = 500;
                    return(taskExecutionContext.GetNumericRangeBlocks(x => x.WithRange(startNumber, maxJourneyId, maxBlockSize)));
                }
                throw new Exception("Could not acquire a critical section, aborted task");
            }
        }