Beispiel #1
0
        public void FindInvalidRollingStartEntrysAndUpdateEntry(int batchSize)
        {
            _logger.LogInformation($"Started maintenance check on rollingstart field for all danish database keys");

            int numberOfRecordsToSkip = 0;
            List <TemporaryExposureKey> databaseKeys;
            List <TemporaryExposureKey> danishKeys = new List <TemporaryExposureKey>();

            do
            {
                databaseKeys = _repository.GetAllKeysNextBatchWithOriginId(numberOfRecordsToSkip, batchSize).ToList();
                foreach (var key in databaseKeys)
                {
                    if (key.Origin.Id == NOcountryCode)
                    {
                        var rollingStartMidnightInUnixTime = ((DateTimeOffset)DateTimeOffset.FromUnixTimeSeconds(key.RollingStartNumber).UtcDateTime.ToUniversalTime().Date).ToUnixTimeSeconds();
                        key.RollingStartNumber = rollingStartMidnightInUnixTime;
                    }
                }
                numberOfRecordsToSkip += databaseKeys.Count;
            }while (databaseKeys.Count > 0);

            _repository.UpdateKeysRollingStartField(danishKeys);
            _logger.LogInformation($"Maintenance check on rollingstart field for all danish database keys completed.");
        }