From afb47bf87d5b9479ed5d00d7a42d6b355e8999ed Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 13 Jun 2024 14:09:51 +0300 Subject: [PATCH] add prepare for integrate wirh clickHouse --- app/app.go | 1 + service/service.go | 1 + service/statistic_svc.go | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/app/app.go b/app/app.go index 156dfbc..fb77db0 100644 --- a/app/app.go +++ b/app/app.go @@ -68,6 +68,7 @@ type Options struct { KafkaGroup string `env:"KAFKA_GROUP" default:"mailnotifier"` TrashLogHost string `env:"TRASH_LOG_HOST" default:"localhost:7113"` ModuleLogger string `env:"MODULE_LOGGER" default:"core-local"` + ClickHouseCred string `env:"CLICK_HOUSE_CRED"` } func New(ctx context.Context, opts interface{}, ver appInit.Version) (appInit.CommonApp, error) { diff --git a/service/service.go b/service/service.go index d6644b4..27cee03 100644 --- a/service/service.go +++ b/service/service.go @@ -73,4 +73,5 @@ func (s *Service) Register(app *fiber.App) { app.Post("/statistic/:quizID/general", s.GetGeneralStatistics) app.Post("/statistic/:quizID/questions", s.GetQuestionsStatistics) app.Post("/statistic", s.AllServiceStatistics) + app.Get("/statistics/:quizId/pipelines", s.GetPipelinesStatistics) } diff --git a/service/statistic_svc.go b/service/statistic_svc.go index 12d38e6..d944ed1 100644 --- a/service/statistic_svc.go +++ b/service/statistic_svc.go @@ -105,3 +105,18 @@ func (s *Service) AllServiceStatistics(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusOK).JSON(allSvcStats) } + +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") + } + + quizIDStr := ctx.Params("quizID") + quizID, err := strconv.ParseInt(quizIDStr, 10, 64) + if err != nil { + return ctx.Status(fiber.StatusBadRequest).SendString("Invalid quiz ID format") + } + + return ctx.Status(fiber.StatusOK).JSON("allSvcStats") +}