Skip to content

Commit 2e1d9cd

Browse files
author
James
committed
remove the fetching and incrementing of the index field
1 parent 51fbccd commit 2e1d9cd

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

models/commit_status.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -216,30 +216,12 @@ func NewCommitStatus(opts NewCommitStatusOptions) error {
216216
opts.CommitStatus.CreatorID = opts.Creator.ID
217217
opts.CommitStatus.RepoID = opts.Repo.ID
218218

219-
// Get the next Status Index
220-
var nextIndex int64
221-
lastCommitStatus := &CommitStatus{
222-
SHA: opts.SHA,
223-
RepoID: opts.Repo.ID,
224-
}
225-
has, err := sess.Desc("index").Limit(1).Get(lastCommitStatus)
226-
if err != nil {
227-
if err := sess.Rollback(); err != nil {
228-
log.Error("NewCommitStatus: sess.Rollback: %v", err)
229-
}
230-
return fmt.Errorf("NewCommitStatus[%s, %s]: %v", repoPath, opts.SHA, err)
231-
}
232-
if has {
233-
log.Debug("NewCommitStatus[%s, %s]: found", repoPath, opts.SHA)
234-
nextIndex = lastCommitStatus.Index
235-
}
236-
opts.CommitStatus.Index = nextIndex + 1
237-
log.Debug("NewCommitStatus[%s, %s]: %d", repoPath, opts.SHA, opts.CommitStatus.Index)
219+
log.Debug("NewCommitStatus[%s, %s]", repoPath, opts.SHA)
238220

239221
opts.CommitStatus.ContextHash = hashCommitStatusContext(opts.CommitStatus.Context)
240222

241223
// Insert new CommitStatus
242-
if _, err = sess.Insert(opts.CommitStatus); err != nil {
224+
if _, err := sess.Insert(opts.CommitStatus); err != nil {
243225
if err := sess.Rollback(); err != nil {
244226
log.Error("Insert CommitStatus: sess.Rollback: %v", err)
245227
}

0 commit comments

Comments
 (0)