Skip to content

Commit

Permalink
Simplify query
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Oct 16, 2023
1 parent 3b2ac97 commit a019b80
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/api/internal/db/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package db

import (
"fmt"

"github.com/volatiletech/null/v8"

"github.com/e2b-dev/infra/packages/api/internal/db/models"
Expand All @@ -12,9 +11,7 @@ import (
func (db *DB) GetDefaultTeamFromUserID(userID string) (result *models.Team, err error) {
userWhere := models.UsersTeamWhere.UserID.EQ(userID)
defaultTeamWhere := models.TeamWhere.IsDefault.EQ(null.BoolFrom(true))
joinTeam := qm.InnerJoin(models.TableNames.Teams + " on " + models.TableNames.UsersTeams + "." + models.UsersTeamColumns.TeamID + " = " + models.TableNames.Teams + "." + models.TeamColumns.ID)

userTeam, err := models.UsersTeams(qm.Load(models.UsersTeamRels.Team), joinTeam, userWhere, defaultTeamWhere).One(db.Client)
userTeam, err := models.UsersTeams(qm.Load(models.UsersTeamRels.Team, defaultTeamWhere), userWhere).One(db.Client)
if err != nil {
errMsg := fmt.Errorf("failed to list envs: %w", err)
fmt.Println(errMsg.Error())
Expand Down

1 comment on commit a019b80

@ValentaTomas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Please sign in to comment.