示例#1
0
  public TurboIssue(String repoId, Issue issue) {
    this.id = issue.getNumber();
    this.title = issue.getTitle() == null ? "" : issue.getTitle();
    this.creator = issue.getUser().getLogin();
    this.createdAt = Utility.dateToLocalDateTime(issue.getCreatedAt());
    this.isPullRequest = isPullRequest(issue);

    this.description = issue.getBody() == null ? "" : issue.getBody();
    this.updatedAt =
        issue.getUpdatedAt() != null
            ? Utility.dateToLocalDateTime(issue.getUpdatedAt())
            : this.createdAt;
    this.commentCount = issue.getComments();
    this.isOpen = issue.getState().equals(STATE_OPEN);
    this.assignee =
        issue.getAssignee() == null
            ? Optional.empty()
            : Optional.of(issue.getAssignee().getLogin());
    this.labels = issue.getLabels().stream().map(Label::getName).collect(Collectors.toList());
    this.milestone =
        issue.getMilestone() == null
            ? Optional.empty()
            : Optional.of(issue.getMilestone().getNumber());

    this.metadata = IssueMetadata.empty();
    this.repoId = repoId;
    this.markedReadAt = Optional.empty();
  }
示例#2
0
  /**
   * Combines data from a corresponding pull request with data in this issue This method returns a
   * new combined issue and does not mutate this issue
   *
   * @param pullRequest
   * @return new new combined issue
   */
  public TurboIssue combineWithPullRequest(PullRequest pullRequest) {
    TurboIssue newIssue = new TurboIssue(this);

    if (pullRequest.getUpdatedAt() == null) {
      return newIssue;
    }

    LocalDateTime pullRequestUpdatedAt = Utility.dateToLocalDateTime(pullRequest.getUpdatedAt());
    if (pullRequestUpdatedAt.isBefore(newIssue.getUpdatedAt())) {
      return newIssue;
    }

    newIssue.setUpdatedAt(pullRequestUpdatedAt);
    return newIssue;
  }