Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Nov 23, 2023
1 parent 3c15676 commit a6feddc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
4 changes: 3 additions & 1 deletion internal/controller/meta/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
type AdminController struct {
fx.In

DB *bun.DB
PatternRepo *repo.DropPattern
PatternElementRepo *repo.DropPatternElement
RecognitionDefectRepo *repo.RecognitionDefect
Expand Down Expand Up @@ -475,7 +476,8 @@ func (c *AdminController) RejectRulesReevaluationApply(ctx *fiber.Ctx) error {
changeSet := evaluation.ChangeSet()

err = c.DB.RunInTx(ctx.UserContext(), nil, func(ictx context.Context, tx bun.Tx) error {
for _, change := range changeSet {
chunks := lo.Chunk(changeSet, 100)
for _, changeChunk := range chunks {
log.Debug().
Str("evt.name", "admin.reject_rules.reevaluation.apply_chunk").
Int("chunk_size", len(changeChunk)).
Expand Down
6 changes: 4 additions & 2 deletions internal/repo/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package repo

import (
"context"
"database/sql"

"github.com/pkg/errors"
"github.com/uptrace/bun"

"exusiai.dev/backend-next/internal/model"
Expand All @@ -24,9 +26,9 @@ func (r *Activity) GetActivities(ctx context.Context) ([]*model.Activity, error)
})
}

func (c *Activity) GetActivityById(ctx context.Context, activityId int) (*model.Activity, error) {
func (r *Activity) GetActivityById(ctx context.Context, activityId int) (*model.Activity, error) {
var activity model.Activity
err := c.DB.NewSelect().
err := r.db.NewSelect().
Model(&activity).
Where("activity_id = ?", activityId).
Scan(ctx)
Expand Down
6 changes: 3 additions & 3 deletions internal/repo/drop_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ func (r *DropInfo) GetDropInfosWithFilters(ctx context.Context, server string, t
return results, nil
}

func (s *DropInfo) GetDropInfosByServerAndRangeId(ctx context.Context, server string, rangeId int) ([]*model.DropInfo, error) {
func (r *DropInfo) GetDropInfosByServerAndRangeId(ctx context.Context, server string, rangeId int) ([]*model.DropInfo, error) {
var dropInfo []*model.DropInfo
err := s.DB.NewSelect().
err := r.db.NewSelect().
Model(&dropInfo).
Where("server = ?", server).
Where("range_id = ?", rangeId).
Expand All @@ -193,7 +193,7 @@ func (s *DropInfo) CloneDropInfosFromCN(ctx context.Context, originRangeId int,
dropInfo.RangeID = destRangeId
dropInfo.Server = server
}
_, err = s.DB.NewInsert().Model(&dropInfos).Exec(ctx)
_, err = s.db.NewInsert().Model(&dropInfos).Exec(ctx)
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion internal/repo/drop_pattern_element.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package repo

import (
"context"
"database/sql"

"github.com/pkg/errors"
"github.com/uptrace/bun"

"exusiai.dev/backend-next/internal/model"
Expand Down Expand Up @@ -71,7 +73,7 @@ func (r *DropPatternElement) GetDropPatternElementsByPatternId(ctx context.Conte

func (r *DropPatternElement) GetDropPatternElementsByPatternIds(ctx context.Context, patternIds []int) ([]*model.DropPatternElement, error) {
var elements []*model.DropPatternElement
err := r.DB.NewSelect().
err := r.db.NewSelect().
Model(&elements).
Where("drop_pattern_id IN (?)", bun.In(patternIds)).
Order("drop_pattern_id", "quantity DESC", "item_id").
Expand Down
9 changes: 6 additions & 3 deletions internal/repo/property.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package repo

import (
"context"
"database/sql"

"github.com/pkg/errors"
"github.com/uptrace/bun"

"exusiai.dev/backend-next/internal/model"
"exusiai.dev/backend-next/internal/pkg/pgerr"
"exusiai.dev/backend-next/internal/repo/selector"
)

Expand All @@ -30,9 +33,9 @@ func (r *Property) GetPropertyByKey(ctx context.Context, key string) (*model.Pro
})
}

func (c *Property) UpdatePropertyByKey(ctx context.Context, key string, value string) (*model.Property, error) {
func (r *Property) UpdatePropertyByKey(ctx context.Context, key string, value string) (*model.Property, error) {
var property model.Property
err := c.db.NewSelect().
err := r.db.NewSelect().
Model(&property).
Where("key = ?", key).
Scan(ctx)
Expand All @@ -44,7 +47,7 @@ func (c *Property) UpdatePropertyByKey(ctx context.Context, key string, value st
}

property.Value = value
_, err = c.db.NewUpdate().
_, err = r.db.NewUpdate().
Model(&property).
Where("key = ?", key).
Exec(ctx)
Expand Down
2 changes: 1 addition & 1 deletion internal/repo/recognition_defect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewRecognitionDefect(db *bun.DB) *RecognitionDefect {
return &RecognitionDefect{db: db, sel: selector.New[model.RecognitionDefect](db)}
}

func (s *RecognitionDefect) CreateDefectReportDraft(ctx context.Context, defectReport *model.RecognitionDefect) error {
func (r *RecognitionDefect) CreateDefectReportDraft(ctx context.Context, defectReport *model.RecognitionDefect) error {
defectReport.DefectID = strings.ToLower(ulid.Make().String())

_, err := r.db.NewInsert().
Expand Down

0 comments on commit a6feddc

Please sign in to comment.