@ -64,16 +64,21 @@ func insertIssue(sess *xorm.Session, issue *Issue) error {
} )
labelIDs = append ( labelIDs , label . ID )
}
if len ( issueLabels ) > 0 {
if _ , err := sess . Insert ( issueLabels ) ; err != nil {
return err
}
}
for _ , reaction := range issue . Reactions {
reaction . IssueID = issue . ID
}
if len ( issue . Reactions ) > 0 {
if _ , err := sess . Insert ( issue . Reactions ) ; err != nil {
return err
}
}
cols := make ( [ ] string , 0 )
if ! issue . IsPull {
@ -151,10 +156,12 @@ func InsertIssueComments(comments []*Comment) error {
reaction . IssueID = comment . IssueID
reaction . CommentID = comment . ID
}
if len ( comment . Reactions ) > 0 {
if _ , err := sess . Insert ( comment . Reactions ) ; err != nil {
return err
}
}
}
for issueID := range issueIDs {
if _ , err := sess . Exec ( "UPDATE issue set num_comments = (SELECT count(*) FROM comment WHERE issue_id = ?) WHERE id = ?" , issueID , issueID ) ; err != nil {
@ -196,7 +203,8 @@ func InsertReleases(rels ...*Release) error {
return err
}
for i := 0 ; i < len ( rel . Attachments ) ; i ++ {
if len ( rel . Attachments ) > 0 {
for i := range rel . Attachments {
rel . Attachments [ i ] . ReleaseID = rel . ID
}
@ -204,6 +212,7 @@ func InsertReleases(rels ...*Release) error {
return err
}
}
}
return sess . Commit ( )
}