Skip to content

Commit

Permalink
fix(ui): postgres too many clients error (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Sep 12, 2024
1 parent 3ad2d19 commit c99f4b0
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 29 deletions.
13 changes: 4 additions & 9 deletions api/infra/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,11 @@ func (mgr *PostgresManager) Connect(ignoreExisting bool) error {
return nil
}

func (mgr *PostgresManager) GetDB() (*gorm.DB, error) {
if err := mgr.Connect(false); err != nil {
return nil, err
}
return db, nil
}

func (mgr *PostgresManager) GetDBOrPanic() *gorm.DB {
if err := mgr.Connect(false); err != nil {
panic(err)
if db == nil {
if err := mgr.Connect(false); err != nil {
panic(err)
}
}
return db
}
4 changes: 2 additions & 2 deletions api/router/file_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ func (r *FileRouter) List(c *fiber.Ctx) error {
return errorpkg.NewInvalidQueryParamError("query")
}
opts := service.FileListOptions{
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}
Expand Down
4 changes: 2 additions & 2 deletions api/router/group_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func (r *GroupRouter) List(c *fiber.Ctx) error {
res, err := r.groupSvc.List(service.GroupListOptions{
Query: query,
OrganizationID: c.Query("organization_id"),
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down
4 changes: 2 additions & 2 deletions api/router/insights_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ func (r *InsightsRouter) ListEntities(c *fiber.Ctx) error {
}
res, err := r.insightsSvc.ListEntities(c.Params("id"), service.InsightsListEntitiesOptions{
Query: query,
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down
8 changes: 4 additions & 4 deletions api/router/invitation_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func (r *InvitationRouter) GetIncoming(c *fiber.Ctx) error {
return errorpkg.NewInvalidQueryParamError("sort_order")
}
res, err := r.invitationSvc.GetIncoming(service.InvitationListOptions{
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down Expand Up @@ -199,8 +199,8 @@ func (r *InvitationRouter) GetOutgoing(c *fiber.Ctx) error {
return errorpkg.NewInvalidQueryParamError("sort_order")
}
res, err := r.invitationSvc.GetOutgoing(orgID, service.InvitationListOptions{
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down
4 changes: 2 additions & 2 deletions api/router/organization_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ func (r *OrganizationRouter) List(c *fiber.Ctx) error {
}
res, err := r.orgSvc.List(service.OrganizationListOptions{
Query: query,
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down
4 changes: 2 additions & 2 deletions api/router/snapshot_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func (r *SnapshotRouter) List(c *fiber.Ctx) error {
return errorpkg.NewInvalidQueryParamError("sort_order")
}
res, err := r.snapshotSvc.List(fileID, service.SnapshotListOptions{
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down
4 changes: 2 additions & 2 deletions api/router/task_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func (r *TaskRouter) List(c *fiber.Ctx) error {
}
res, err := r.taskSvc.List(service.TaskListOptions{
Query: query,
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down
4 changes: 2 additions & 2 deletions api/router/user_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func (r *UserRouter) List(c *fiber.Ctx) error {
ExcludeGroupMembers: excludeGroupMembers,
SortBy: sortBy,
SortOrder: sortOrder,
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
}, userID)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions api/router/workspace_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func (r *WorkspaceRouter) List(c *fiber.Ctx) error {
}
res, err := r.workspaceSvc.List(service.WorkspaceListOptions{
Query: query,
Page: uint(page),
Size: uint(size),
Page: uint(page), // #nosec G115
Size: uint(size), // #nosec G115
SortBy: sortBy,
SortOrder: sortOrder,
}, GetUserID(c))
Expand Down

0 comments on commit c99f4b0

Please sign in to comment.