popok 502 fix

This commit is contained in:
Yared Yemane 2025-06-30 18:53:19 +03:00
parent c5796b07f0
commit 3768ff857a
5 changed files with 30 additions and 20 deletions

View File

@ -115,6 +115,7 @@ func main() {
wallet.WalletStore(store), wallet.WalletStore(store),
wallet.TransferStore(store), wallet.TransferStore(store),
notificatioStore, notificatioStore,
notificationSvc,
logger, logger,
) )
@ -206,22 +207,22 @@ func main() {
httpserver.StartTicketCrons(*ticketSvc) httpserver.StartTicketCrons(*ticketSvc)
// Fetch companies and branches for live wallet metrics update // Fetch companies and branches for live wallet metrics update
ctx := context.Background() // ctx := context.Background()
companies := []domain.GetCompany{ // companies := []domain.GetCompany{
{ID: 1, Name: "Company A", WalletBalance: 1000.0}, // {ID: 1, Name: "Company A", WalletBalance: 1000.0},
} // }
branches := []domain.BranchWallet{ // branches := []domain.BranchWallet{
{ID: 10, Name: "Branch Z", CompanyID: 1, Balance: 500.0}, // {ID: 10, Name: "Branch Z", CompanyID: 1, Balance: 500.0},
} // }
notificationSvc.UpdateLiveWalletMetrics(ctx, companies, branches) // notificationSvc.UpdateLiveWalletMetrics(ctx, companies, branches)
if err != nil { // if err != nil {
log.Println("Failed to update live metrics:", err) // log.Println("Failed to update live metrics:", err)
} else { // } else {
log.Println("Live metrics broadcasted successfully") // log.Println("Live metrics broadcasted successfully")
} // }
issueReportingRepo := repository.NewReportedIssueRepository(store) issueReportingRepo := repository.NewReportedIssueRepository(store)

View File

@ -14,11 +14,12 @@ type Service struct {
logger *slog.Logger logger *slog.Logger
} }
func NewService(walletStore WalletStore, transferStore TransferStore, notificationStore notificationservice.NotificationStore, logger *slog.Logger) *Service { func NewService(walletStore WalletStore, transferStore TransferStore, notificationStore notificationservice.NotificationStore, notificationSvc *notificationservice.Service, logger *slog.Logger) *Service {
return &Service{ return &Service{
walletStore: walletStore, walletStore: walletStore,
transferStore: transferStore, transferStore: transferStore,
notificationStore: notificationStore, notificationStore: notificationStore,
notificationSvc: notificationSvc,
logger: logger, logger: logger,
} }
} }

View File

@ -134,7 +134,7 @@ func (s *Service) DeductFromWallet(ctx context.Context, id int64, amount domain.
return domain.Transfer{}, nil return domain.Transfer{}, nil
} }
go s.notificationSvc.UpdateLiveWalletMetricForWallet(ctx, wallet) // go s.notificationSvc.UpdateLiveWalletMetricForWallet(ctx, wallet)
// Log the transfer here for reference // Log the transfer here for reference
newTransfer, err := s.transferStore.CreateTransfer(ctx, domain.CreateTransfer{ newTransfer, err := s.transferStore.CreateTransfer(ctx, domain.CreateTransfer{

View File

@ -108,7 +108,11 @@ func (h *Handler) HandlePlayerInfo(c *fiber.Ctx) error {
func (h *Handler) HandleBet(c *fiber.Ctx) error { func (h *Handler) HandleBet(c *fiber.Ctx) error {
var req domain.PopOKBetRequest var req domain.PopOKBetRequest
if err := c.BodyParser(&req); err != nil { if err := c.BodyParser(&req); err != nil {
return fiber.NewError(fiber.StatusBadRequest, "Invalid bet request") return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
Message: "Invalid bet request",
Error: err.Error(),
})
// return fiber.NewError(fiber.StatusBadRequest, "Invalid bet request")
} }
resp, _ := h.virtualGameSvc.ProcessBet(c.Context(), &req) resp, _ := h.virtualGameSvc.ProcessBet(c.Context(), &req)
@ -179,7 +183,11 @@ func (h *Handler) GetGameList(c *fiber.Ctx) error {
games, err := h.virtualGameSvc.ListGames(c.Context(), currency) games, err := h.virtualGameSvc.ListGames(c.Context(), currency)
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusBadGateway, "failed to fetch games") return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
Message: "Falied to fetch games",
Error: err.Error(),
})
// return fiber.NewError(fiber.StatusBadGateway, "failed to fetch games")
} }
return c.JSON(games) return c.JSON(games)
} }

View File

@ -259,9 +259,9 @@ func (a *App) initAppRoutes() {
group.Post("/veli/start-game", a.authMiddleware, h.StartGame) group.Post("/veli/start-game", a.authMiddleware, h.StartGame)
group.Post("/veli/start-demo-game", a.authMiddleware, h.StartDemoGame) group.Post("/veli/start-demo-game", a.authMiddleware, h.StartDemoGame)
a.fiber.Post("/balance", h.GetBalance) a.fiber.Post("/balance", h.GetBalance)
a.fiber.Post("/bet", h.PlaceBet) // a.fiber.Post("/bet", h.PlaceBet)
a.fiber.Post("/win", h.RegisterWin) // a.fiber.Post("/win", h.RegisterWin)
a.fiber.Post("/cancel", h.CancelTransaction) // a.fiber.Post("/cancel", h.CancelTransaction)
group.Post("/veli/gaming-activity", h.GetGamingActivity) group.Post("/veli/gaming-activity", h.GetGamingActivity)
//mongoDB logs //mongoDB logs