Skip to content

Commit

Permalink
Cleanup paging handling in various tables Closes #52 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI authored Jul 27, 2023
1 parent 0fce356 commit d11e207
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
8 changes: 2 additions & 6 deletions slack/table_slack_access_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ func listAccessLogs(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateD
maxPages := 5

// Reduce the basic request limit down if the user has only requested a small number of rows
limit := d.QueryContext.Limit
if d.QueryContext.Limit != nil {
limit := d.QueryContext.Limit
if *limit < int64(params.Count) {
if *limit < 1 {
params.Count = 1
} else {
params.Count = int(*limit)
}
params.Count = int(*limit)
}
}

Expand Down
8 changes: 2 additions & 6 deletions slack/table_slack_conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,10 @@ func listConversations(ctx context.Context, d *plugin.QueryData, _ *plugin.Hydra
opts := &slack.GetConversationsParameters{Limit: 1000, Types: []string{"public_channel", "private_channel", "im", "mpim"}}

// Reduce the basic request limit down if the user has only requested a small number of rows
limit := d.QueryContext.Limit
if d.QueryContext.Limit != nil {
limit := d.QueryContext.Limit
if *limit < int64(opts.Limit) {
if *limit < 1 {
opts.Limit = 1
} else {
opts.Limit = int(*limit)
}
opts.Limit = int(*limit)
}
}

Expand Down
8 changes: 6 additions & 2 deletions slack/table_slack_conversation_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ func listConversationMembers(ctx context.Context, d *plugin.QueryData, _ *plugin
conversationID := d.EqualsQuals["conversation_id"].GetStringValue()
itemsPerPage := int64(100)
// Reduce the basic request limit down if the user has only requested a small number of rows
if d.QueryContext.Limit != nil && *d.QueryContext.Limit < itemsPerPage {
itemsPerPage = *d.QueryContext.Limit
if d.QueryContext.Limit != nil {
limit := d.QueryContext.Limit
if *limit < itemsPerPage {
itemsPerPage = int64(*limit)
}
}

opts := &slack.GetUsersInConversationParameters{ChannelID: conversationID, Cursor: "", Limit: int(itemsPerPage)}

for {
Expand Down
8 changes: 2 additions & 6 deletions slack/table_slack_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ func listSearches(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateDat
pagesLeft := true

// Reduce the basic request limit down if the user has only requested a small number of rows
limit := d.QueryContext.Limit
if d.QueryContext.Limit != nil {
limit := d.QueryContext.Limit
if *limit < int64(params.Count) {
if *limit < 1 {
params.Count = 1
} else {
params.Count = int(*limit)
}
params.Count = int(*limit)
}
}

Expand Down

0 comments on commit d11e207

Please sign in to comment.