Skip to content

Commit ae4714a

Browse files
committed
fix: fixed tasks returning less items than it should due to a page not containing 100 items, other misc
1 parent 2a7225b commit ae4714a

8 files changed

Lines changed: 70 additions & 15 deletions

File tree

clickup/table_folder.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ func tableClickupFolder() *plugin.Table {
1313
Name: "clickup_folder",
1414
Description: "Obtain folders by specifying either an id or a space_id.",
1515
List: &plugin.ListConfig{
16-
Hydrate: listFolders,
17-
KeyColumns: plugin.SingleColumn("space_id"),
16+
Hydrate: listFolders,
17+
KeyColumns: []*plugin.KeyColumn{
18+
{
19+
Name: "space_id",
20+
Require: plugin.Required,
21+
},
22+
{
23+
Name: "archived",
24+
Require: plugin.Optional,
25+
},
26+
},
1827
},
1928
Get: &plugin.GetConfig{
2029
Hydrate: getFolder,
@@ -31,9 +40,13 @@ func listFolders(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData
3140
}
3241

3342
spaceId := d.EqualsQuals["space_id"].GetStringValue()
34-
plugin.Logger(ctx).Debug("listFolders", "spaceId", spaceId)
43+
archived := false
44+
if d.EqualsQuals["archived"] != nil {
45+
archived = d.EqualsQuals["archived"].GetBoolValue()
46+
}
47+
plugin.Logger(ctx).Debug("listFolders", "spaceId", spaceId, "archived", archived)
3548

36-
folders, _, err := client.Folders.GetFolders(ctx, spaceId, true)
49+
folders, _, err := client.Folders.GetFolders(ctx, spaceId, archived)
3750
if err != nil {
3851
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain folders for space id '%s': %v", spaceId, err))
3952
return nil, fmt.Errorf("unable to obtain folders for space id '%s': %v", spaceId, err)

clickup/table_folderless_list.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,17 @@ func tableClickupFolderlessList() *plugin.Table {
1111
Name: "clickup_folderless_list",
1212
Description: "Obtain lists not associated to a folder by providing a space_id.",
1313
List: &plugin.ListConfig{
14-
KeyColumns: plugin.SingleColumn("space_id"),
15-
Hydrate: listFolderlessLists,
14+
KeyColumns: []*plugin.KeyColumn{
15+
{
16+
Name: "space_id",
17+
Require: plugin.Required,
18+
},
19+
{
20+
Name: "archived",
21+
Require: plugin.Optional,
22+
},
23+
},
24+
Hydrate: listFolderlessLists,
1625
},
1726
Columns: listColumns(),
1827
}
@@ -25,9 +34,13 @@ func listFolderlessLists(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd
2534
}
2635

2736
spaceId := d.EqualsQuals["space_id"].GetStringValue()
28-
plugin.Logger(ctx).Debug("listFolderlessLists", "spaceId", spaceId)
37+
archived := false
38+
if d.EqualsQuals["archived"] != nil {
39+
archived = d.EqualsQuals["archived"].GetBoolValue()
40+
}
41+
plugin.Logger(ctx).Debug("listFolderlessLists", "spaceId", spaceId, "archived", archived)
2942

30-
lists, _, err := client.Lists.GetFolderlessLists(ctx, spaceId, true)
43+
lists, _, err := client.Lists.GetFolderlessLists(ctx, spaceId, archived)
3144
if err != nil {
3245
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain folderless lists for space id '%s': %v", spaceId, err))
3346
return nil, fmt.Errorf("unable to obtain folderless lists for space id '%s': %v", spaceId, err)

clickup/table_list.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ func tableClickupList() *plugin.Table {
1313
Name: "clickup_list",
1414
Description: "Obtain lists that are associated to a folder by specifying either an id or a folder_id.",
1515
List: &plugin.ListConfig{
16-
KeyColumns: plugin.SingleColumn("folder_id"),
17-
Hydrate: listLists,
16+
KeyColumns: []*plugin.KeyColumn{
17+
{
18+
Name: "folder_id",
19+
Require: plugin.Required,
20+
},
21+
{
22+
Name: "archived",
23+
Require: plugin.Optional,
24+
},
25+
},
26+
Hydrate: listLists,
1827
},
1928
Get: &plugin.GetConfig{
2029
KeyColumns: plugin.SingleColumn("id"),
@@ -31,9 +40,13 @@ func listLists(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
3140
}
3241

3342
folderId := d.EqualsQuals["folder_id"].GetStringValue()
34-
plugin.Logger(ctx).Debug("listLists", "folderId", folderId)
43+
archived := false
44+
if d.EqualsQuals["archived"] != nil {
45+
archived = d.EqualsQuals["archived"].GetBoolValue()
46+
}
47+
plugin.Logger(ctx).Debug("listLists", "folderId", folderId, "archived", archived)
3548

36-
lists, _, err := client.Lists.GetLists(ctx, folderId, true)
49+
lists, _, err := client.Lists.GetLists(ctx, folderId, archived)
3750
if err != nil {
3851
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain lists for folder id '%s': %v", folderId, err))
3952
return nil, fmt.Errorf("unable to obtain lists for folder id '%s': %v", folderId, err)

clickup/table_task.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ func tableClickupTask() *plugin.Table {
2828
Name: "status",
2929
Require: plugin.Optional,
3030
},
31+
{
32+
Name: "archived",
33+
Require: plugin.Optional,
34+
},
3135
},
3236
},
3337
Get: &plugin.GetConfig{
@@ -49,7 +53,7 @@ func listTasks(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
4953
// Default options
5054
opts := &clickup.GetTasksOptions{
5155
Page: 0,
52-
Archived: true,
56+
Archived: false,
5357
IncludeClosed: true,
5458
Subtasks: true,
5559
}
@@ -62,6 +66,10 @@ func listTasks(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
6266
plugin.Logger(ctx).Debug("listTasks", "status", q["status"].GetStringValue())
6367
opts.Statuses = []string{q["status"].GetStringValue()}
6468
}
69+
if q["archived"] != nil {
70+
plugin.Logger(ctx).Debug("listTasks", "archived", q["archived"].GetBoolValue())
71+
opts.Archived = q["archived"].GetBoolValue()
72+
}
6573

6674
var ts []clickup.Task
6775
for {
@@ -89,8 +97,8 @@ func listTasks(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
8997
d.StreamListItem(ctx, t)
9098
}
9199

92-
if len(ts) < 100 {
93-
plugin.Logger(ctx).Debug("listTasks - exiting as page returned < 100 items", "page", opts.Page, "results", len(ts))
100+
if len(ts) == 0 {
101+
plugin.Logger(ctx).Debug("listTasks", "teamId", teamId, "exiting, page returned 0 results.")
94102
break
95103
}
96104

docs/tables/clickup_folder.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Obtain information about folders within your ClickUp environment.
44

55
However you **MUST** specify either an `id` (single) or `space_id` (for multiple tasks) in the WHERE or JOIN clause.
66

7+
> Note: by default `archived` items won't be returned, to return archived items only set `archived = true` in the where clause.
8+
79
## Examples
810

911
### Get a folder by id

docs/tables/clickup_folderless_list.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Obtain information about lists that aren't associated to folders within your Cli
44

55
However you **MUST** specify a `space_id` in the WHERE or JOIN clause.
66

7+
> Note: by default `archived` items won't be returned, to return archived items only set `archived = true` in the where clause.
8+
79
## Examples
810

911
### List lists for a space that are not associated with a folder.

docs/tables/clickup_list.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Obtain information about lists within your ClickUp environment.
44

55
However you **MUST** specify either an `id` (single) or `folder_id` (for multiple tasks) in the WHERE or JOIN clause.
66

7+
> Note: by default `archived` items won't be returned, to return archived items only set `archived = true` in the where clause.
8+
79
## Examples
810

911
### Get a list by id

docs/tables/clickup_task.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Obtain information about tasks assigned to a specific team within your ClickUp e
44

55
However you **MUST** specify either an `id` (single) or either a `list_id` or `team_id` (for multiple tasks) in the WHERE or JOIN clause.
66

7+
> Note: by default `archived` items won't be returned, to return archived items only set `archived = true` in the where clause.
8+
79
## Examples
810

911
### Get a task by id

0 commit comments

Comments
 (0)