private async Task <IEnumerable <Recommending.Candidate> > GetExpertCandidates(SophiaDbContext dbContext, long subscriptionId, Octokit.PullRequest pullRequest, IReadOnlyList <Octokit.PullRequestFile> pullRequestFiles, int topCandidatesLength)
        {
            var recommender = new CodeReviewerRecommender(RecommenderType.Chrev, dbContext);
            var candidates  = await recommender.Recommend(subscriptionId, pullRequest, pullRequestFiles, topCandidatesLength);

            return(candidates);
        }
Esempio n. 2
0
        private async Task GetCandidates(EventContext eventContext, SophiaDbContext dbContext, int issueNumber, long repositoryId, Data.Models.Subscription subscription, int topCandidatesLength)
        {
            var installationClient = eventContext.InstallationContext.Client;
            var recommender        = new CodeReviewerRecommender(RecommenderType.Chrev, dbContext);

            var pullRequest = await installationClient.PullRequest.Get(repositoryId, issueNumber);

            var pullRequestFiles = await installationClient.PullRequest.Files(repositoryId, issueNumber);

            var candidates = await recommender.Recommend(subscription.Id, pullRequest, pullRequestFiles, topCandidatesLength);

            await SaveCandidates(dbContext, candidates, pullRequest, subscription);

            var message = GenerateMessage(candidates, pullRequestFiles);

            await installationClient.Issue.Comment.Create(repositoryId, issueNumber, message);
        }