Beispiel #1
0
        private async static Task ScrapeUserInfoAsync(
            ScrapingTask scrapingTask, IGitHubClient gitHubClient,
            ITransaction tx, IUserRepoSearchActor userRepoSearchActor,
            IReliableConcurrentQueue <ScrapingTask> secondTaskQueue)
        {
            Result <UserInfo> result = await gitHubClient
                                       .GetUserInfoAsync(scrapingTask.AuthToken);

            if (result.Success)
            {
                await userRepoSearchActor.SetUserInfoAsync(result.Data);

                await secondTaskQueue.EnqueueAsync(tx, new ScrapingTask
                {
                    Type      = ScrapingTaskType.FollowingRepositories,
                    AuthToken = scrapingTask.AuthToken,
                    UserLogin = scrapingTask.UserLogin
                });
            }
        }
Beispiel #2
0
        private async static Task ScrapeFollowingRepositoriesAsync(
            ScrapingTask scrapingTask,
            IGitHubClient gitHubClient,
            ITransaction tx,
            IUserRepoSearchActor userRepoSearchActor,
            IReliableConcurrentQueue <ScrapingTask> secondTaskQueue)
        {
            Result <UserInfo> userInfoResult = await gitHubClient
                                               .GetUserInfoAsync(scrapingTask.AuthToken);

            if (!userInfoResult.Success)
            {
                return;
            }

            Result <IEnumerable <Repository> > repositoriesResult = await gitHubClient
                                                                    .ScrapeFollowingRepositoriesAsync(scrapingTask.AuthToken);

            if (!repositoriesResult.Success)
            {
                return;
            }

            List <ScheduledRepository> scheduledRepositories = repositoriesResult.Data.Select(
                repository => new ScheduledRepository
            {
                Name  = repository.Name,
                Owner = repository.Owner
            }).ToList();

            await secondTaskQueue.EnqueueAsync(tx, new ScrapingTask
            {
                Type                  = ScrapingTaskType.Repository,
                AuthToken             = scrapingTask.AuthToken,
                UserLogin             = scrapingTask.UserLogin,
                ScheduledRepositories = scheduledRepositories
            });
        }