Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Oct 10, 2024
1 parent 5547fca commit 8294143
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tasks:
silent: true
desc: Run 'golangci-lint'
cmds:
- golangci-lint run --fix
- golangci-lint --path-prefix "{{ .USER_WORKING_DIR }}" run --fix

test:
desc: Run mocked tests, need nothing.
Expand Down
9 changes: 7 additions & 2 deletions internal/collections/infra/mysql_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ func (r mysqlRepo) updateOrCreateSubjectCollection(
r.updateSubject(ctx, subject.ID)

if obj.Rate != originalCollection.Rate {
r.reCountSubjectRate(ctx, subject.ID, originalCollection.Rate, obj.Rate)
if err := r.reCountSubjectRate(ctx, subject.ID, originalCollection.Rate, obj.Rate); err != nil {
r.log.Error("failed to update collection counts", zap.Error(err), zap.Uint32("subject_id", subject.ID))
}
}

return nil
Expand Down Expand Up @@ -594,6 +596,7 @@ func (r mysqlRepo) reCountSubjectCollection(ctx context.Context, subjectID model
})
}

//nolint:mnd
func (r mysqlRepo) reCountSubjectRate(ctx context.Context, subjectID model.SubjectID, before uint8, after uint8) error {
var counts []struct {
Rate uint8 `gorm:"rate"`
Expand All @@ -603,7 +606,9 @@ func (r mysqlRepo) reCountSubjectRate(ctx context.Context, subjectID model.Subje
return r.q.Transaction(func(tx *query.Query) error {
err := tx.DB().WithContext(ctx).Raw(`
select interest_rate as rate, count(interest_rate) as total from chii_subject_interests
where interest_subject_id = ? and interest_private = 0 and interest_rate != 0 and ((interest_rate = ?) or (interest_rate = ?))
where interest_subject_id = ? and
interest_private = 0 and
interest_rate != 0 and ((interest_rate = ?) or (interest_rate = ?))
group by interest_rate
`, subjectID, before, after).Scan(&counts).Error
if err != nil {
Expand Down

0 comments on commit 8294143

Please sign in to comment.