Skip to content

Commit

Permalink
fix - Adding missing checks in paginated results
Browse files Browse the repository at this point in the history
  • Loading branch information
GtheSheep authored Oct 2, 2023
2 parents 871f614 + 504e27e commit d75e7f6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.14
0.0.17
6 changes: 6 additions & 0 deletions tableau/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func (c *Client) GetGroup(groupID string) (*Group, error) {
if err != nil {
return nil, err
}
// check if we found the group in this page
for i, group := range groupListResponse.GroupsResponse.Groups {
if group.ID == groupID {
return &groupListResponse.GroupsResponse.Groups[i], nil
}
}
}

return nil, fmt.Errorf("Did not find group ID %s", groupID)
Expand Down
6 changes: 6 additions & 0 deletions tableau/group_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ func (c *Client) GetGroupUser(groupID, userID string) (*User, error) {
if err != nil {
return nil, err
}
// Check this page of data for the GroupUser match
for i, user := range groupUsersListResponse.GroupUsersResponse.Users {
if user.ID == userID {
return &groupUsersListResponse.GroupUsersResponse.Users[i], nil
}
}
}

return nil, fmt.Errorf("Did not find user ID %s in group ID %s", userID, groupID)
Expand Down
6 changes: 6 additions & 0 deletions tableau/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func (c *Client) GetProject(projectID string) (*Project, error) {
if err != nil {
return nil, err
}
// Check page for project match
for i, project := range projectListResponse.ProjectsResponse.Projects {
if project.ID == projectID {
return &projectListResponse.ProjectsResponse.Projects[i], nil
}
}
}

return nil, fmt.Errorf("Did not find project ID %s", projectID)
Expand Down

0 comments on commit d75e7f6

Please sign in to comment.