예제 #1
0
        private async Task <List <TemporaryExposureKey> > FilterDuplicateIncommingKeys(List <TemporaryExposureKey> incomingKeys)
        {
            int  numberOfRecordsToSkip    = 0;
            int  batchSize                = _appSettingsConfig.MaxKeysPerFile;
            long lowestRollingStartNumber = GetLowestRollingStartNumber(incomingKeys);
            var  existingKeysBatch        = await _temporaryExposureKeyRepository.GetNextBatchOfKeysWithRollingStartNumberThresholdAsync(lowestRollingStartNumber, numberOfRecordsToSkip, batchSize);

            while (existingKeysBatch.Count != 0)
            {
                incomingKeys           = _exposureKeyMapper.FilterDuplicateKeys(incomingKeys, existingKeysBatch).ToList();
                numberOfRecordsToSkip += existingKeysBatch.Count;
                existingKeysBatch      = await _temporaryExposureKeyRepository.GetNextBatchOfKeysWithRollingStartNumberThresholdAsync(lowestRollingStartNumber, numberOfRecordsToSkip, batchSize);
            }
            return(incomingKeys);
        }
예제 #2
0
        public async Task <IList <TemporaryExposureKey> > RemoveKeyDuplicatesAsync(IList <TemporaryExposureKey> downloadedKeys)
        {
            var numberOfRecordsToSkip = 0;
            var filteredKeys          = downloadedKeys;
            IList <TemporaryExposureKey> dbKeysBatch;

            do
            {
                var validRollingStartNumberThreshold =
                    ConvertOffsetDaysToRollingStartNumber(OutdatedKeysDayOffset);

                dbKeysBatch = await _tempKeyRepository.GetNextBatchOfKeysWithRollingStartNumberThresholdAsync(validRollingStartNumberThreshold, numberOfRecordsToSkip, BatchSize);

                filteredKeys           = _exposureKeyMapper.FilterDuplicateKeys(filteredKeys, dbKeysBatch);
                numberOfRecordsToSkip += dbKeysBatch.Count;
            } while (dbKeysBatch.Count == BatchSize);

            return(filteredKeys);
        }