func NewIssue(gIssue *github.Issue, repository string) (*sql.Issue, error) {
	if gIssue.Number == nil ||
		gIssue.Title == nil ||
		gIssue.User == nil ||
		gIssue.User.Login == nil ||
		gIssue.State == nil ||
		gIssue.Comments == nil ||
		gIssue.CreatedAt == nil ||
		gIssue.UpdatedAt == nil {
		return nil, fmt.Errorf("Issue is missing mandatory field: %+v", gIssue)
	}

	var closedAt *time.Time
	if gIssue.ClosedAt != nil {
		closedAt = gIssue.ClosedAt
	}
	assignees, err := newAssignees(
		*gIssue.Number,
		gIssue.Assignees, repository)
	if err != nil {
		return nil, err
	}
	var body string
	if gIssue.Body != nil {
		body = *gIssue.Body
	}
	isPR := (gIssue.PullRequestLinks != nil && gIssue.PullRequestLinks.URL != nil)
	labels, err := newLabels(
		*gIssue.Number, gIssue.Labels, repository)
	if err != nil {
		return nil, err
	}

	return &sql.Issue{
		ID:             strconv.Itoa(*gIssue.Number),
		Labels:         labels,
		Title:          *gIssue.Title,
		Body:           body,
		User:           *gIssue.User.Login,
		Assignees:      assignees,
		State:          *gIssue.State,
		Comments:       *gIssue.Comments,
		IsPR:           isPR,
		IssueClosedAt:  closedAt,
		IssueCreatedAt: *gIssue.CreatedAt,
		IssueUpdatedAt: *gIssue.UpdatedAt,
		Repository:     strings.ToLower(repository),
	}, nil
}
func NewIssue(gIssue *github.Issue, repository string) (*sql.Issue, error) {
	if gIssue.Number == nil ||
		gIssue.Title == nil ||
		gIssue.User == nil ||
		gIssue.User.Login == nil ||
		gIssue.State == nil ||
		gIssue.Comments == nil ||
		gIssue.CreatedAt == nil ||
		gIssue.UpdatedAt == nil {
		return nil, fmt.Errorf("Issue is missing mandatory field: %+v", gIssue)
	}

	var closedAt *time.Time
	if gIssue.ClosedAt != nil {
		closedAt = gIssue.ClosedAt
	}
	assignees, err := newAssignees(
		*gIssue.Number,
		gIssue.Assignees, repository)
	if err != nil {
		return nil, err
	}
	var body string
	if gIssue.Body != nil {
		body = *gIssue.Body
	}
	isPR := (gIssue.PullRequestLinks != nil && gIssue.PullRequestLinks.URL != nil)
	labels, err := newLabels(
		*gIssue.Number, gIssue.Labels, repository)
	if err != nil {
		return nil, err
	}

	return &sql.Issue{
		ID:             strconv.Itoa(*gIssue.Number),
		Labels:         labels,
		Title:          *gIssue.Title,
		Body:           body,
		User:           *gIssue.User.Login,
		Assignees:      assignees,
		State:          *gIssue.State,
		Comments:       *gIssue.Comments,
		IsPR:           isPR,
		IssueClosedAt:  closedAt,
		IssueCreatedAt: *gIssue.CreatedAt,
		IssueUpdatedAt: *gIssue.UpdatedAt,
		Repository:     strings.ToLower(repository),
	}, nil
}
// NewIssue creates a new (orm) Issue from a github Issue