From a7ea5f824e4a259f755cbef003b15c7845a95895 Mon Sep 17 00:00:00 2001 From: Idhibhat Pankam Date: Thu, 22 Feb 2024 13:18:50 +0700 Subject: [PATCH] fix: remove tmp logs --- src/app/service/pet/pet.service.go | 24 ------------------------ src/app/utils/pet/pet.utils.go | 29 ++--------------------------- 2 files changed, 2 insertions(+), 51 deletions(-) diff --git a/src/app/service/pet/pet.service.go b/src/app/service/pet/pet.service.go index 57fd9a4..1a68238 100644 --- a/src/app/service/pet/pet.service.go +++ b/src/app/service/pet/pet.service.go @@ -98,27 +98,9 @@ func (s *Service) FindAll(_ context.Context, req *proto.FindAllPetRequest) (res log.Error().Err(err).Str("service", "event").Str("module", "find all").Msg("Error while querying all events") return nil, status.Error(codes.Unavailable, "Internal error") } - log.Info(). - Str("service", "pet"). - Str("module", "repo.FindAll").Interface("pets", pets).Msg("") - log.Info(). - Str("service", "pet"). - Str("module", "repo.FindAll").Msgf("number: %d", len(pets)) petUtils.FilterPet(&pets, req) - log.Info(). - Str("service", "pet"). - Str("module", "filtered pets").Interface("filteredPets", pets).Msg("") - log.Info(). - Str("service", "pet"). - Str("module", "filtered pets").Msgf("number: %d", len(pets)) petUtils.PaginatePets(&pets, req.Page, req.PageSize, &metaData) - log.Info(). - Str("service", "pet"). - Str("module", "paginated pets").Interface("paginatedPets", pets).Msg("") - log.Info(). - Str("service", "pet"). - Str("module", "paginated pets").Msgf("number: %d", len(pets)) for _, pet := range pets { images, err := s.imageService.FindByPetId(pet.ID.String()) @@ -128,12 +110,6 @@ func (s *Service) FindAll(_ context.Context, req *proto.FindAllPetRequest) (res imagesList[pet.ID.String()] = images } petWithImages, err := petUtils.RawToDtoList(&pets, imagesList, req) - log.Info(). - Str("service", "pet"). - Str("module", "pet with images").Interface("petWithImages", petWithImages).Msg("") - log.Info(). - Str("service", "pet"). - Str("module", "pet with images").Msgf("number: %d", len(pets)) if err != nil { return nil, status.Error(codes.Internal, fmt.Sprintf("error converting raw to dto list: %v", err)) diff --git a/src/app/utils/pet/pet.utils.go b/src/app/utils/pet/pet.utils.go index 50f7cff..ec6b77d 100644 --- a/src/app/utils/pet/pet.utils.go +++ b/src/app/utils/pet/pet.utils.go @@ -22,12 +22,7 @@ func FilterPet(in *[]*pet.Pet, query *proto.FindAllPetRequest) error { if query.MaxAge == 0 { query.MaxAge = math.MaxInt32 } - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet").Msgf("minAge: %d, maxAge: %d", query.MinAge, query.MaxAge) - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet").Interface("query", query).Msgf("query") + var results []*pet.Pet for _, p := range *in { res, err := filterAge(p, query.MinAge, query.MaxAge) @@ -35,44 +30,24 @@ func FilterPet(in *[]*pet.Pet, query *proto.FindAllPetRequest) error { return err } if !res { - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet reject").Msgf("pet id = %s age not in range", p.ID.String()) continue } if query.Search != "" && !strings.Contains(p.Name, query.Search) { - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet reject").Msg("not in search") continue } if query.Type != "" && p.Type != query.Type { - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet reject").Msg("not the type") continue } if query.Gender != "" && p.Gender != petConst.Gender(query.Gender) { - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet reject").Msg("not the gender") continue } if query.Color != "" && p.Color != query.Color { - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet reject").Msg("not the color") continue } if query.Origin != "" && p.Origin != query.Origin { - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet reject").Msg("not the origin") continue } - log.Info(). - Str("service", "filter pet"). - Str("module", "FilterPet accept").Interface("pet", p).Msgf("pet accepted") + results = append(results, p) } *in = results