Skip to content

Commit

Permalink
BEDS 322/annotate endpoints (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly authored Sep 17, 2024
1 parent fa2d7bc commit 9fbcabc
Show file tree
Hide file tree
Showing 6 changed files with 469 additions and 42 deletions.
7 changes: 5 additions & 2 deletions backend/pkg/api/data_access/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@ func (d *DataAccessService) GetUserInfo(ctx context.Context, userId uint64) (*t.
}{}
err = d.userReader.GetContext(ctx, &result, `SELECT email, COALESCE(user_group, '') as user_group FROM users WHERE id = $1`, userId)
if err != nil {
return nil, fmt.Errorf("error getting userEmail for user %v: %w", userId, err)
if errors.Is(err, sql.ErrNoRows) {
return nil, fmt.Errorf("%w: user not found", ErrNotFound)
}
return nil, err
}
userInfo.Email = result.Email
userInfo.UserGroup = result.UserGroup
Expand Down Expand Up @@ -764,7 +767,7 @@ func (d *DataAccessService) GetUserDashboards(ctx context.Context, userId uint64

err := wg.Wait()
if err != nil {
return nil, fmt.Errorf("error retrieving user dashboards data: %v", err)
return nil, fmt.Errorf("error retrieving user dashboards data: %w", err)
}

// Fill the result
Expand Down
8 changes: 4 additions & 4 deletions backend/pkg/api/data_access/vdb_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (d *DataAccessService) GetValidatorDashboardInfo(ctx context.Context, dashb

err := wg.Wait()
if err != nil {
return nil, fmt.Errorf("error retrieving user dashboards data: %v", err)
return nil, fmt.Errorf("error retrieving user dashboards data: %w", err)
}

return result, nil
Expand Down Expand Up @@ -329,7 +329,7 @@ func (d *DataAccessService) GetValidatorDashboardOverview(ctx context.Context, d

validators, err := d.getDashboardValidators(ctx, dashboardId, nil)
if err != nil {
return fmt.Errorf("error retrieving validators from dashboard id: %v", err)
return fmt.Errorf("error retrieving validators from dashboard id: %w", err)
}

if dashboardId.Validators != nil || dashboardId.AggregateGroups {
Expand Down Expand Up @@ -475,7 +475,7 @@ func (d *DataAccessService) GetValidatorDashboardOverview(ctx context.Context, d

query, args, err := ds.Prepared(true).ToSQL()
if err != nil {
return fmt.Errorf("error preparing query: %v", err)
return fmt.Errorf("error preparing query: %w", err)
}

err = d.clickhouseReader.GetContext(ctx, &queryResult, query, args...)
Expand Down Expand Up @@ -511,7 +511,7 @@ func (d *DataAccessService) GetValidatorDashboardOverview(ctx context.Context, d
err = eg.Wait()

if err != nil {
return nil, fmt.Errorf("error retrieving validator dashboard overview data: %v", err)
return nil, fmt.Errorf("error retrieving validator dashboard overview data: %w", err)
}

return &data, nil
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/api/handlers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func checkSort[T enums.EnumFactory[T]](v *validationError, sortString string) *t
return nil
}
if len(sortSplit) == 1 {
sortSplit = append(sortSplit, "")
sortSplit = append(sortSplit, ":asc")
}
sortCol := checkEnum[T](v, sortSplit[0], "sort")
order := v.parseSortOrder(sortSplit[1])
Expand Down
Loading

0 comments on commit 9fbcabc

Please sign in to comment.