diff --git a/app/app.go b/app/app.go index fa04d5e..9214547 100644 --- a/app/app.go +++ b/app/app.go @@ -22,7 +22,7 @@ import ( "penahub.gitlab.yandexcloud.net/backend/quiz/core/server" "penahub.gitlab.yandexcloud.net/backend/quiz/core/service" "penahub.gitlab.yandexcloud.net/backend/quiz/core/tools" - "penahub.gitlab.yandexcloud.net/external/trashlog.git/wrappers/zaptrashlog" + "penahub.gitlab.yandexcloud.net/external/trashlog/wrappers/zaptrashlog" "time" ) @@ -190,7 +190,9 @@ func New(ctx context.Context, opts interface{}, ver appInit.Version) (appInit.Co pgdal.Close() } if chDal != nil { - chDal.Close(ctx) + if derr := chDal.Close(ctx); derr != nil { + fmt.Printf("error closing clickhouse: %v", derr) + } } err := grpc.Stop(ctx) err = app.Shutdown() diff --git a/go.mod b/go.mod index 29dff1f..9568bd5 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,8 @@ require ( penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240630122905-2747a8c00d81 penahub.gitlab.yandexcloud.net/backend/quiz/worker.git v0.0.0-20240421230341-0e086fcbb990 - penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240615192328-b2f5dffe92ae + penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240803124813-79e62d2acf3c + penahub.gitlab.yandexcloud.net/external/trashlog v0.1.5 ) require ( @@ -52,7 +53,6 @@ require ( github.com/richardlehane/msoleps v1.0.3 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rs/xid v1.5.0 // indirect - github.com/tealeg/xlsx v1.0.5 // indirect github.com/twmb/franz-go/pkg/kmsg v1.8.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.53.0 // indirect @@ -69,5 +69,4 @@ require ( gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240803124813-79e62d2acf3c // indirect ) diff --git a/go.sum b/go.sum index d34c68a..7083fe0 100644 --- a/go.sum +++ b/go.sum @@ -140,8 +140,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE= -github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33 h1:N9f/Q+2Ssa+yDcbfaoLTYvXmdeyUUxsJKdPUVsjSmiA= github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33/go.mod h1:rpcH99JknBh8seZmlOlUg51gasZH6QH34oXNsIwYT6E= github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf h1:TJJm6KcBssmbWzplF5lzixXl1RBAi/ViPs1GaSOkhwo= @@ -263,7 +261,6 @@ google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6h google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -286,19 +283,11 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c h1:CWb4UcuNXhd1KTNOmy2U0TJO4+Qxgxrj5cwkyFqbgrk= penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240607202348-efe5f2bf3e8c/go.mod h1:+bPxq2wfW5S1gd+83vZYmHm33AE7nEBfznWS8AM1TKE= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240620093753-d2537b8ba40e h1:o9ZXlQGrKgEEavBcw+YdO7kun8xt5xKVlvls7z49D5k= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240620093753-d2537b8ba40e/go.mod h1:nfZkoj8MCYaoP+xiPeUn5D0lIzinUr1qDkNfX0ng9rk= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240620122425-3755aa4ac985 h1:i05GzLIL+iLirwoba2QihIxqKkylSiw6OQFrSAyL4GE= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240620122425-3755aa4ac985/go.mod h1:nfZkoj8MCYaoP+xiPeUn5D0lIzinUr1qDkNfX0ng9rk= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240620193727-f8a59de8ed8b h1:Ka4nopPla7x3ItcBrou15lobkBmigS6hrGaZnelUnmQ= -penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240620193727-f8a59de8ed8b/go.mod h1:nfZkoj8MCYaoP+xiPeUn5D0lIzinUr1qDkNfX0ng9rk= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240630122905-2747a8c00d81 h1:HSEcPZ8PVOrhj6d7/7MjHibxu/+3KXUeFbd/JpZ//bI= penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240630122905-2747a8c00d81/go.mod h1:nfZkoj8MCYaoP+xiPeUn5D0lIzinUr1qDkNfX0ng9rk= penahub.gitlab.yandexcloud.net/backend/quiz/worker.git v0.0.0-20240421230341-0e086fcbb990 h1:jiO8GWO+3sCnDAV8/NAV8tQIUwae/I6/xiDilW7zf0o= penahub.gitlab.yandexcloud.net/backend/quiz/worker.git v0.0.0-20240421230341-0e086fcbb990/go.mod h1:zswBuTwmEsFHBVRu1nkG3/Fwylk5Vcm8OUm9iWxccSE= penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240803124813-79e62d2acf3c h1:imtXaIVscs8it6SfAmDxjNxqQSF44GgCTl1N6JT6unA= penahub.gitlab.yandexcloud.net/devops/linters/golang.git v0.0.0-20240803124813-79e62d2acf3c/go.mod h1:i7M72RIpkSjcQtHID6KKj9RT/EYZ1rxS6tIPKWa/BSY= -penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240605170345-09de7d822830 h1:OElRKl1ig9/X4b+TmKhiZNjzIv4QMhH4/V0IfwWoCCY= -penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240605170345-09de7d822830/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4= -penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240615192328-b2f5dffe92ae h1:vlGInCsQSDA464q7OMv3EWGUviQWQdEcpLc8HIRo+rE= -penahub.gitlab.yandexcloud.net/external/trashlog.git v0.1.2-0.20240615192328-b2f5dffe92ae/go.mod h1:3ml0dAGT8U8RhpevKBfRgG6yKZum8EI2uJxAb2WCIy4= +penahub.gitlab.yandexcloud.net/external/trashlog v0.1.5 h1:amsK0bkSJxBisk334aFo5ZmVPvN1dBT0Sv5j3V5IsT8= +penahub.gitlab.yandexcloud.net/external/trashlog v0.1.5/go.mod h1:J8kQNEP4bL7ZNKHxuT4tfe6a3FHyovpAPkyytN4qllc= diff --git a/service/statistic_svc.go b/service/statistic_svc.go index f02fb3b..432ef2b 100644 --- a/service/statistic_svc.go +++ b/service/statistic_svc.go @@ -73,7 +73,7 @@ func (s *Service) GetQuestionsStatistics(ctx *fiber.Ctx) error { var req DeviceStatReq if err := ctx.BodyParser(&req); err != nil { - ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") + return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } questionsStats, err := s.dal.StatisticsRepo.GetQuestionsStatistics(ctx.Context(), statistics.DeviceStatReq{ @@ -95,7 +95,7 @@ type StatisticReq struct { func (s *Service) AllServiceStatistics(ctx *fiber.Ctx) error { var req StatisticReq if err := ctx.BodyParser(&req); err != nil { - ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") + return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } allSvcStats, err := s.dal.StatisticsRepo.AllServiceStatistics(ctx.Context(), req.From, req.To) @@ -109,7 +109,7 @@ func (s *Service) AllServiceStatistics(ctx *fiber.Ctx) error { func (s *Service) GetPipelinesStatistics(ctx *fiber.Ctx) error { var req StatisticReq if err := ctx.BodyParser(&req); err != nil { - ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") + return ctx.Status(fiber.StatusBadRequest).SendString("Invalid request data") } quizIDStr := ctx.Params("quizID") diff --git a/tests/utils.go b/tests/utils.go index 4d904f3..01c54a9 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -111,7 +111,11 @@ func registerUser(login string) *jwt.Token { if err != nil { panic(err) } - defer resp.Body.Close() + defer func() { + if derr := resp.Body.Close(); derr != nil { + fmt.Printf("error close response body in registerUser: %v", derr) + } + }() bytes, err := io.ReadAll(resp.Body) if err != nil { diff --git a/tools/tools.go b/tools/tools.go index 61e01d0..e44171f 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -110,8 +110,14 @@ func WriteDataToExcel(buffer io.Writer, questions []model.Question, answers []mo if err != nil { fmt.Println(err.Error()) } - file.SetColWidth(sheet, ToAlphaString(count), ToAlphaString(count), 50) - file.SetRowHeight(sheet, row, 150) + err = file.SetColWidth(sheet, ToAlphaString(count), ToAlphaString(count), 50) + if err != nil { + fmt.Println(err.Error()) + } + err = file.SetRowHeight(sheet, row, 150) + if err != nil { + fmt.Println(err.Error()) + } if err := file.AddPictureFromBytes(sheet, cell, picture); err != nil { fmt.Println(err.Error()) } @@ -229,7 +235,12 @@ func downloadImage(url string) (*excelize.Picture, error) { if err != nil { return nil, err } - defer resp.Body.Close() + + defer func() { + if derr := resp.Body.Close(); derr != nil { + fmt.Printf("error close response body in downloadImage: %v", derr) + } + }() imgData, err := ioutil.ReadAll(resp.Body) if err != nil {