diff --git a/.golangci.yaml b/.golangci.yaml index cc89ece..6c25667 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -44,7 +44,7 @@ linters: - revive - rowserrcheck - staticcheck - - stylecheck + # - stylecheck - thelper - typecheck - unconvert diff --git a/internal/interface/controller/rest/history/history.go b/internal/interface/controller/rest/history/history.go index f4636eb..d8ef7d6 100644 --- a/internal/interface/controller/rest/history/history.go +++ b/internal/interface/controller/rest/history/history.go @@ -16,7 +16,7 @@ import ( type historyService interface { GetHistoryList(context.Context, *dto.GetHistories) (*models.PaginationResponse[models.History], errors.Error) - GetRecentTariffs(context.Context, string) ([]models.TariffID, errors.Error) //new + GetRecentTariffs(context.Context, string) ([]models.TariffID, errors.Error) // new } type Deps struct { @@ -71,7 +71,7 @@ func (receiver *Controller) GetHistoryList(ctx echo.Context, params swagger.GetH return ctx.JSON(http.StatusOK, histories) } -// TODO:tests +// TODO:tests. func (receiver *Controller) GetRecentTariffs(ctx echo.Context) error { userID, ok := ctx.Get(models.AuthJWTDecodedUserIDKey).(string) if !ok { diff --git a/internal/interface/repository/history.go b/internal/interface/repository/history.go index f288a27..6800851 100644 --- a/internal/interface/repository/history.go +++ b/internal/interface/repository/history.go @@ -3,9 +3,7 @@ package repository import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" "log" - "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/fields" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" @@ -14,6 +12,7 @@ import ( "go.uber.org/zap" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/dto" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors" + "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/fields" "penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models" mongoWrapper "penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/mongo" ) @@ -111,9 +110,8 @@ func (receiver *HistoryRepository) CountAll(ctx context.Context, dto *dto.GetHis } // TODO:tests -// GetRecentTariffs method for processing a user request with data aggregation with a limit of 100 sorted in descending order +// GetRecentTariffs method for processing a user request with data aggregation with a limit of 100 sorted in descending order. func (receiver *HistoryRepository) GetRecentTariffs(ctx context.Context, userID string) ([]models.TariffID, errors.Error) { - matchStage := bson.D{ {Key: "$match", Value: bson.D{ {Key: fields.History.UserID, Value: userID}, diff --git a/internal/service/history/history.go b/internal/service/history/history.go index 4672da7..465894c 100644 --- a/internal/service/history/history.go +++ b/internal/service/history/history.go @@ -16,7 +16,7 @@ type historyRepository interface { CountAll(context.Context, *dto.GetHistories) (int64, errors.Error) FindMany(context.Context, *dto.GetHistories) ([]models.History, errors.Error) Insert(context.Context, *models.History) (*models.History, errors.Error) - GetRecentTariffs(context.Context, string) ([]models.TariffID, errors.Error) //new + GetRecentTariffs(context.Context, string) ([]models.TariffID, errors.Error) // new } type Deps struct { @@ -92,9 +92,8 @@ func (receiver *Service) CreateHistory(ctx context.Context, history *models.Hist return createdHistory, nil } -// TODO:tests +// TODO:tests. func (receiver *Service) GetRecentTariffs(ctx context.Context, userID string) ([]models.TariffID, errors.Error) { - if userID == "" { receiver.logger.Error("user id is missing in of ") return nil, errors.New(