integration issues
This commit is contained in:
parent
6e6ed2c9a9
commit
d43b12c589
|
|
@ -41,6 +41,8 @@ WHERE (
|
||||||
is_featured = sqlc.narg('is_featured')
|
is_featured = sqlc.narg('is_featured')
|
||||||
OR sqlc.narg('is_featured') IS NULL
|
OR sqlc.narg('is_featured') IS NULL
|
||||||
)
|
)
|
||||||
|
ORDER BY is_featured DESC,
|
||||||
|
name ASC
|
||||||
LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
|
LIMIT sqlc.narg('limit') OFFSET sqlc.narg('offset');
|
||||||
-- name: GetFeaturedLeagues :many
|
-- name: GetFeaturedLeagues :many
|
||||||
SELECT id,
|
SELECT id,
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ WHERE (
|
||||||
is_featured = $4
|
is_featured = $4
|
||||||
OR $4 IS NULL
|
OR $4 IS NULL
|
||||||
)
|
)
|
||||||
|
ORDER BY is_featured DESC,
|
||||||
|
name ASC
|
||||||
LIMIT $6 OFFSET $5
|
LIMIT $6 OFFSET $5
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ func ConvertGetCompany(company GetCompany) GetCompanyRes {
|
||||||
AdminFirstName: company.AdminFirstName,
|
AdminFirstName: company.AdminFirstName,
|
||||||
AdminLastName: company.AdminLastName,
|
AdminLastName: company.AdminLastName,
|
||||||
AdminPhoneNumber: company.AdminPhoneNumber,
|
AdminPhoneNumber: company.AdminPhoneNumber,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ var (
|
||||||
ISSUE_TYPE_ODDS ReportedIssueType = "odds"
|
ISSUE_TYPE_ODDS ReportedIssueType = "odds"
|
||||||
ISSUE_TYPE_EVENTS ReportedIssueType = "events"
|
ISSUE_TYPE_EVENTS ReportedIssueType = "events"
|
||||||
ISSUE_TYPE_BRANCH ReportedIssueType = "branch"
|
ISSUE_TYPE_BRANCH ReportedIssueType = "branch"
|
||||||
ISSUE_TYPE_USER ReportedIssueType = "branch"
|
ISSUE_TYPE_USER ReportedIssueType = "user"
|
||||||
ISSUE_TYPE_LOGIN ReportedIssueType = "login"
|
ISSUE_TYPE_LOGIN ReportedIssueType = "login"
|
||||||
ISSUE_TYPE_REGISTER ReportedIssueType = "register"
|
ISSUE_TYPE_REGISTER ReportedIssueType = "register"
|
||||||
ISSUE_TYPE_RESET_PASSWORD ReportedIssueType = "reset_password"
|
ISSUE_TYPE_RESET_PASSWORD ReportedIssueType = "reset_password"
|
||||||
|
|
|
||||||
|
|
@ -544,16 +544,16 @@ func (s *Store) GetBetSummary(ctx context.Context, filter domain.ReportFilter) (
|
||||||
return 0, 0, 0, 0, 0, 0, fmt.Errorf("failed to get bet summary: %w", err)
|
return 0, 0, 0, 0, 0, 0, fmt.Errorf("failed to get bet summary: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
domain.MongoDBLogger.Info("GetBetSummary executed successfully",
|
// domain.MongoDBLogger.Info("GetBetSummary executed successfully",
|
||||||
zap.String("query", query),
|
// zap.String("query", query),
|
||||||
zap.Any("args", args),
|
// zap.Any("args", args),
|
||||||
zap.Float64("totalStakes", float64(totalStakes)), // convert if needed
|
// zap.Float64("totalStakes", float64(totalStakes)), // convert if needed
|
||||||
zap.Int64("totalBets", totalBets),
|
// zap.Int64("totalBets", totalBets),
|
||||||
zap.Int64("activeBets", activeBets),
|
// zap.Int64("activeBets", activeBets),
|
||||||
zap.Int64("totalWins", totalWins),
|
// zap.Int64("totalWins", totalWins),
|
||||||
zap.Int64("totalLosses", totalLosses),
|
// zap.Int64("totalLosses", totalLosses),
|
||||||
zap.Float64("winBalance", float64(winBalance)), // convert if needed
|
// zap.Float64("winBalance", float64(winBalance)), // convert if needed
|
||||||
)
|
// )
|
||||||
return totalStakes, totalBets, activeBets, totalWins, totalLosses, winBalance, nil
|
return totalStakes, totalBets, activeBets, totalWins, totalLosses, winBalance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ func (s *Store) UpdateLeague(ctx context.Context, league domain.UpdateLeague) er
|
||||||
},
|
},
|
||||||
IsFeatured: pgtype.Bool{
|
IsFeatured: pgtype.Bool{
|
||||||
Bool: league.IsFeatured.Value,
|
Bool: league.IsFeatured.Value,
|
||||||
Valid: league.IsActive.Valid,
|
Valid: league.IsFeatured.Valid,
|
||||||
},
|
},
|
||||||
SportID: pgtype.Int4{
|
SportID: pgtype.Int4{
|
||||||
Int32: league.SportID.Value,
|
Int32: league.SportID.Value,
|
||||||
|
|
|
||||||
|
|
@ -24,22 +24,22 @@ func StartDataFetchingCrons(eventService eventsvc.Service, oddsService oddssvc.S
|
||||||
spec string
|
spec string
|
||||||
task func()
|
task func()
|
||||||
}{
|
}{
|
||||||
// {
|
{
|
||||||
// spec: "0 0 * * * *", // Every 1 hour
|
spec: "0 0 * * * *", // Every 1 hour
|
||||||
// task: func() {
|
task: func() {
|
||||||
// if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
|
if err := eventService.FetchUpcomingEvents(context.Background()); err != nil {
|
||||||
// log.Printf("FetchUpcomingEvents error: %v", err)
|
log.Printf("FetchUpcomingEvents error: %v", err)
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events)
|
spec: "0 0 * * * *", // Every 1 hour (since its takes that long to fetch all the events)
|
||||||
// task: func() {
|
task: func() {
|
||||||
// if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
if err := oddsService.FetchNonLiveOdds(context.Background()); err != nil {
|
||||||
// log.Printf("FetchNonLiveOdds error: %v", err)
|
log.Printf("FetchNonLiveOdds error: %v", err)
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
spec: "0 */5 * * * *", // Every 5 Minutes
|
spec: "0 */5 * * * *", // Every 5 Minutes
|
||||||
task: func() {
|
task: func() {
|
||||||
|
|
|
||||||
|
|
@ -99,12 +99,13 @@ func (h *Handler) CreateBranch(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
branch, err := h.branchSvc.CreateBranch(c.Context(), domain.CreateBranch{
|
branch, err := h.branchSvc.CreateBranch(c.Context(), domain.CreateBranch{
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Location: req.Location,
|
Location: req.Location,
|
||||||
WalletID: newWallet.ID,
|
WalletID: newWallet.ID,
|
||||||
BranchManagerID: req.BranchManagerID,
|
BranchManagerID: req.BranchManagerID,
|
||||||
CompanyID: checkedCompanyID,
|
CompanyID: checkedCompanyID,
|
||||||
IsSelfOwned: IsSelfOwned,
|
IsSelfOwned: IsSelfOwned,
|
||||||
|
ProfitPercentage: req.ProfitPercentage,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -619,7 +620,6 @@ func (h *Handler) GetBranchOperations(c *fiber.Ctx) error {
|
||||||
return response.WriteJSON(c, fiber.StatusOK, "Branch Operations retrieved successfully", result, nil)
|
return response.WriteJSON(c, fiber.StatusOK, "Branch Operations retrieved successfully", result, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetAllBranchLocations godoc
|
// GetAllBranchLocations godoc
|
||||||
// @Summary Gets all branch locations
|
// @Summary Gets all branch locations
|
||||||
// @Description Gets all branch locations
|
// @Description Gets all branch locations
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ func (h *Handler) CreateCompany(c *fiber.Ctx) error {
|
||||||
user, err := h.userSvc.GetUserByID(c.Context(), req.AdminID)
|
user, err := h.userSvc.GetUserByID(c.Context(), req.AdminID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.mongoLoggerSvc.Error("Error fetching user",
|
h.mongoLoggerSvc.Error("Error fetching user",
|
||||||
|
zap.Int("admin_id", int(req.AdminID)),
|
||||||
zap.Int("status_code", fiber.StatusInternalServerError),
|
zap.Int("status_code", fiber.StatusInternalServerError),
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
zap.Time("timestamp", time.Now()),
|
zap.Time("timestamp", time.Now()),
|
||||||
|
|
@ -76,9 +77,10 @@ func (h *Handler) CreateCompany(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
company, err := h.companySvc.CreateCompany(c.Context(), domain.CreateCompany{
|
company, err := h.companySvc.CreateCompany(c.Context(), domain.CreateCompany{
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
AdminID: user.ID,
|
AdminID: user.ID,
|
||||||
WalletID: newWallet.ID,
|
WalletID: newWallet.ID,
|
||||||
|
DeductedPercentage: req.DeductedPercentage,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,23 @@ func (h *Handler) GetAllIssues(c *fiber.Ctx) error {
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, "Failed to get all issues:"+err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, "Failed to get all issues:"+err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(issues)
|
results := make([]domain.ReportedIssue, len(issues))
|
||||||
|
for i, issue := range issues {
|
||||||
|
results[i] = domain.ReportedIssue{
|
||||||
|
ID: issue.ID,
|
||||||
|
UserID: issue.UserID,
|
||||||
|
UserRole: domain.Role(issue.UserRole),
|
||||||
|
Subject: issue.Subject,
|
||||||
|
Description: issue.Description,
|
||||||
|
IssueType: domain.ReportedIssueType(issue.IssueType),
|
||||||
|
Status: domain.ReportedIssueStatus(issue.Status),
|
||||||
|
// Metadata: issue.Metadata,
|
||||||
|
CreatedAt: issue.CreatedAt.Time,
|
||||||
|
UpdatedAt: issue.UpdatedAt.Time,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.JSON(results)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateIssueStatus godoc
|
// UpdateIssueStatus godoc
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ func (h *Handler) SetLeagueActive(c *fiber.Ctx) error {
|
||||||
|
|
||||||
if err := h.leagueSvc.SetLeagueActive(c.Context(), int64(leagueId), req.IsActive); err != nil {
|
if err := h.leagueSvc.SetLeagueActive(c.Context(), int64(leagueId), req.IsActive); err != nil {
|
||||||
h.mongoLoggerSvc.Error("Failed to update league active",
|
h.mongoLoggerSvc.Error("Failed to update league active",
|
||||||
zap.Int64("userID", int64(leagueId)),
|
zap.Int64("leagueID", int64(leagueId)),
|
||||||
zap.Bool("is_active", req.IsActive),
|
zap.Bool("is_active", req.IsActive),
|
||||||
zap.Int("status_code", fiber.StatusInternalServerError),
|
zap.Int("status_code", fiber.StatusInternalServerError),
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
|
@ -149,6 +149,14 @@ func (h *Handler) SetLeagueActive(c *fiber.Ctx) error {
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, "Failed to update league:"+err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, "Failed to update league:"+err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h.mongoLoggerSvc.Info("League Active has been successfully updated",
|
||||||
|
zap.Int64("userID", int64(leagueId)),
|
||||||
|
zap.Int64("leagueID", int64(leagueId)),
|
||||||
|
zap.Bool("is_active", req.IsActive),
|
||||||
|
zap.Int("status_code", fiber.StatusOK),
|
||||||
|
zap.Time("timestamp", time.Now()),
|
||||||
|
)
|
||||||
|
|
||||||
return response.WriteJSON(c, fiber.StatusOK, "League updated successfully", nil, nil)
|
return response.WriteJSON(c, fiber.StatusOK, "League updated successfully", nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,6 +214,10 @@ func (h *Handler) SetLeagueFeatured(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
err = h.leagueSvc.UpdateLeague(c.Context(), domain.UpdateLeague{
|
err = h.leagueSvc.UpdateLeague(c.Context(), domain.UpdateLeague{
|
||||||
ID: int64(leagueId),
|
ID: int64(leagueId),
|
||||||
|
IsFeatured: domain.ValidBool{
|
||||||
|
Value: req.IsFeatured,
|
||||||
|
Valid: true,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.mongoLoggerSvc.Error("Failed to update league",
|
h.mongoLoggerSvc.Error("Failed to update league",
|
||||||
|
|
@ -216,6 +228,12 @@ func (h *Handler) SetLeagueFeatured(c *fiber.Ctx) error {
|
||||||
)
|
)
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, "Failed to update league:"+err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, "Failed to update league:"+err.Error())
|
||||||
}
|
}
|
||||||
|
h.mongoLoggerSvc.Info("League Featured has been successfully updated",
|
||||||
|
zap.Int64("userID", int64(leagueId)),
|
||||||
|
zap.Int64("leagueID", int64(leagueId)),
|
||||||
|
zap.Bool("is_featured", req.IsFeatured),
|
||||||
|
zap.Int("status_code", fiber.StatusOK),
|
||||||
|
zap.Time("timestamp", time.Now()),
|
||||||
|
)
|
||||||
return response.WriteJSON(c, fiber.StatusOK, "League updated successfully", nil, nil)
|
return response.WriteJSON(c, fiber.StatusOK, "League updated successfully", nil, nil)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ func GetLogsHandler(appCtx context.Context) fiber.Handler {
|
||||||
}
|
}
|
||||||
defer cursor.Close(appCtx)
|
defer cursor.Close(appCtx)
|
||||||
|
|
||||||
var logs []domain.LogEntry
|
var logs []domain.LogEntry = make([]domain.LogEntry, 0)
|
||||||
if err := cursor.All(appCtx, &logs); err != nil {
|
if err := cursor.All(appCtx, &logs); err != nil {
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, "Cursor decoding error: "+err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, "Cursor decoding error: "+err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +113,7 @@ func GetLogsHandler(appCtx context.Context) fiber.Handler {
|
||||||
// Prepare response
|
// Prepare response
|
||||||
response := domain.LogResponse{
|
response := domain.LogResponse{
|
||||||
Message: "Logs fetched successfully",
|
Message: "Logs fetched successfully",
|
||||||
Data: logs,
|
Data: logs,
|
||||||
Pagination: domain.Pagination{
|
Pagination: domain.Pagination{
|
||||||
Total: int(total),
|
Total: int(total),
|
||||||
TotalPages: totalPages,
|
TotalPages: totalPages,
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ func (h *Handler) ConnectSocket(c *fiber.Ctx) error {
|
||||||
zap.Time("timestamp", time.Now()),
|
zap.Time("timestamp", time.Now()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
h.mongoLoggerSvc.Warn("Unexpected WebSocket closure",
|
h.mongoLoggerSvc.Info("Unexpected WebSocket closure",
|
||||||
zap.Int64("userID", userID),
|
zap.Int64("userID", userID),
|
||||||
zap.Int("status_code", fiber.StatusBadRequest),
|
zap.Int("status_code", fiber.StatusBadRequest),
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,13 @@ import (
|
||||||
// @Failure 500 {object} domain.ErrorResponse
|
// @Failure 500 {object} domain.ErrorResponse
|
||||||
// @Router /api/v1/reports/dashboard [get]
|
// @Router /api/v1/reports/dashboard [get]
|
||||||
func (h *Handler) GetDashboardReport(c *fiber.Ctx) error {
|
func (h *Handler) GetDashboardReport(c *fiber.Ctx) error {
|
||||||
|
role := c.Locals("role").(domain.Role)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Parse query parameters
|
// Parse query parameters
|
||||||
filter, err := parseReportFilter(c)
|
filter, err := parseReportFilter(c, role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusBadRequest).JSON(domain.ErrorResponse{
|
||||||
Message: "Invalid filter parameters",
|
Message: "Invalid filter parameters",
|
||||||
|
|
@ -70,10 +72,9 @@ func (h *Handler) GetDashboardReport(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseReportFilter parses query parameters into ReportFilter
|
// parseReportFilter parses query parameters into ReportFilter
|
||||||
func parseReportFilter(c *fiber.Ctx) (domain.ReportFilter, error) {
|
func parseReportFilter(c *fiber.Ctx, role domain.Role) (domain.ReportFilter, error) {
|
||||||
var filter domain.ReportFilter
|
var filter domain.ReportFilter
|
||||||
var err error
|
var err error
|
||||||
role := c.Locals("role").(domain.Role)
|
|
||||||
|
|
||||||
if c.Query("company_id") != "" && role == domain.RoleSuperAdmin {
|
if c.Query("company_id") != "" && role == domain.RoleSuperAdmin {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ func (a *App) initAppRoutes() {
|
||||||
a.fiber.Get("/", func(c *fiber.Ctx) error {
|
a.fiber.Get("/", func(c *fiber.Ctx) error {
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
"message": "Welcome to the FortuneBet API",
|
"message": "Welcome to the FortuneBet API",
|
||||||
"version": "1.0dev10",
|
"version": "1.0dev11",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// Swagger
|
// Swagger
|
||||||
|
|
@ -65,7 +65,7 @@ func (a *App) initAppRoutes() {
|
||||||
groupV1.Get("/", func(c *fiber.Ctx) error {
|
groupV1.Get("/", func(c *fiber.Ctx) error {
|
||||||
return c.JSON(fiber.Map{
|
return c.JSON(fiber.Map{
|
||||||
"message": "FortuneBet API V1 pre-alpha",
|
"message": "FortuneBet API V1 pre-alpha",
|
||||||
"version": "1.0dev10",
|
"version": "1.0dev11",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// Auth Routes
|
// Auth Routes
|
||||||
|
|
@ -241,7 +241,7 @@ func (a *App) initAppRoutes() {
|
||||||
groupV1.Get("/currencies/convert", h.ConvertCurrency)
|
groupV1.Get("/currencies/convert", h.ConvertCurrency)
|
||||||
|
|
||||||
//Report Routes
|
//Report Routes
|
||||||
groupV1.Get("/reports/dashboard", h.GetDashboardReport)
|
groupV1.Get("/reports/dashboard", a.authMiddleware, a.OnlyAdminAndAbove, h.GetDashboardReport)
|
||||||
groupV1.Get("/report-files/download/:filename", a.authMiddleware, a.OnlyAdminAndAbove, h.DownloadReportFile)
|
groupV1.Get("/report-files/download/:filename", a.authMiddleware, a.OnlyAdminAndAbove, h.DownloadReportFile)
|
||||||
groupV1.Get("/report-files/list", a.authMiddleware, a.OnlyAdminAndAbove, h.ListReportFiles)
|
groupV1.Get("/report-files/list", a.authMiddleware, a.OnlyAdminAndAbove, h.ListReportFiles)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user