Ejemplo n.º 1
0
        private async Task <IList <PinnedRepo> > UploadReposAsync(IEnumerable <PinnedRepo> repos)
        {
            // faster
            // var uploadTasks = reposList.Select(_repoRepository.UploadRepoAsync);
            // var initiatedUploadTasks =
            //     (from uploadTask in uploadTasks select AwaitUploadAndSendUpdate(uploadTask)).ToArray();
            // var uploadedRepos = await Task.WhenAll(initiatedUploadTasks);
            // _logger.LogInformation(
            //     "Completed uploading repos. {uploadedRepos}",
            //     JsonConvert.SerializeObject(uploadedRepos)
            // );
            // return uploadedRepos;
            var uploadedRepos = new List <PinnedRepo>();

            foreach (var pinnedRepo in repos)
            {
                var result = await AwaitUploadAndSendUpdate(_repoRepository.UploadRepoAsync(pinnedRepo));

                uploadedRepos.Add(result);
            }

            _logger.LogInformation(
                "Completed uploading repos. {uploadedReposNames}",
                string.Join(" | ", uploadedRepos.Select(repo => repo.Name))
                );
            return(uploadedRepos);
        }