class PullRequestTrial(object): def __init__(self, git_user, repo_name): self.git_user = git_user self.repo_name = repo_name self.client = GitPullRequestsClient(settings.GIT_USER, settings.GIT_PASS) def analyze_pull_request(self, pull, players): """Check whether we have seen this pull request before, and if so, whether it has changed. If there's potentially new information here, get the comments and analyze them. """ print 'inspecting', pull['number'] key = PULL_UPDATED_KEY % pull['number'] updated = redis.get(key) if updated and updated == pull['updated_at']: return author = get_author(pull, players) for comment in self.client.get_pull_request_comments(self.git_user, self.repo_name, pull['number']): award_comment_achievements(pull, comment, author, players) redis.set(key, pull['updated_at']) def __call__(self, contest): for pull in self.client.recent_pull_requests(self.git_user, self.repo_name): self.analyze_pull_request(pull, contest.players)
def __init__(self, git_user, repo_name): self.git_user = git_user self.repo_name = repo_name self.client = GitPullRequestsClient(settings.GIT_USER, settings.GIT_PASS)