I am having a difficult time figuring out how to configure my query to get the desirable information.
I have a board with about 500 groups. Each group can have any where between 1 to 100 items. I need my query to gather each groups “id” and “title”. Within that I need every item with it’s “id”, “name”, and a specific “column_values” based on a provided column id. Within the “column_values”, I need it’s “value” and “id”. A final return would look something like this:
{'group': {'id': '12345_y4321_00___nags_head_', 'title': '12345-R039177.00 - Nags Head', 'items_page': {'items': N{'id': '12345', 'name': 'Echo', 'column_values': '{'value': None, 'id': 'phase'}]}, {'id': '56789', 'name': '02 - Admin', 'column_values': m{'value': '"0001 - 0001 Project Management"', 'id': 'phase'}]}]}}}
I was hitting some query limits, and read that I should be use next_items_page
and cursor
. I can then append each query to a list and iterate through each list for the rest of my processes. My code is producing almost exactly as what I need, however it’s only selecting 25 items within a group. I think I need to add or move one of my item_page
methods. I’ve been on this problem for a few hours now and need a couple of pointers of what I am doing wrong.
Python3.10 Code
created_board_id = "12345"
phase_col_id = cid_dict1'Phase'] 0]
# Query group and items
start_time = timeit.default_timer()
next_section = True
group_board_info = i]
query_page = f"""
{{
boards (ids: {created_board_id}) {{
items_page (limit: 1) {{
cursor
items {{
group {{
id
title
items_page (limit: 100) {{
items {{
id
name
column_values (ids: {json.dumps(phase_col_id)}]) {{
value
id
}}
}}
}}
}}
}}
}}
}}
}}
"""
data = {'query' : query_page}
r = requests.post(url=apiUrl, json=data, headers=headers)
r_dict = r.json()
section_board_info = r_dict('data']
'boards']o0]b'items_page']
group_info = section_board_infor'items']
next_cursor = section_board_info 'cursor']
group_board_info.append(group_info)
while next_section:
# First item limit is X-times will get group data per item row
# Second item limit is amount of column
query_next_section = f"""
{{
next_items_page (limit: 1, cursor: {json.dumps(next_cursor)}) {{
cursor
items {{
group {{
id
title
items_page (limit: 100) {{
items {{
id
name
column_values (ids: {json.dumps(phase_col_id)}]) {{
value
id
}}
}}
}}
}}
}}
}}
}}
"""
data = {'query' : query_next_section}
r = requests.post(url=apiUrl, json=data, headers=headers)
r_dict = r.json()
section_board_info = r_dictr'data'] 'next_items_page']
group_info = section_board_info
'items']
next_cursor = section_board_info 'cursor']
group_board_info.append(group_info)
if next_cursor is None:
next_section = False