Skip to content

Commit

Permalink
done!
Browse files Browse the repository at this point in the history
  • Loading branch information
willnaoosmith committed Oct 5, 2023
1 parent 6ae9403 commit 62167c1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 54 deletions.
98 changes: 49 additions & 49 deletions monday/query_joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,33 @@ def mutate_subitem_query(parent_item_id, subitem_name, column_values,
def get_item_query(board_id, column_id, value):
query = '''query
{
items_by_column_values(
board_id: %s,
column_id: %s,
column_value: "%s"
items_page_by_column_values(
board_id: %s,
columns: [{column_id: "%s", column_values: ["%s"]}]
) {
id
name
updates {
id
body
}
group {
id
title
}
column_values {
cursor
items {
id
text
value
name
updates {
id
body
}
group {
id
title
}
column_values {
id
text
value
}
}
}
}''' % (board_id, column_id, value)

return query


def get_item_by_id_query(ids):
query = '''query
{
Expand Down Expand Up @@ -295,10 +296,9 @@ def delete_update_query(item_id):
return query


def get_updates_for_item_query(board, item, limit):
query = '''query
{boards (ids: %s)
{items (ids: %s) {
def get_updates_for_item_query(item, limit):
query = '''query{
items(ids: %s){
updates (limit: %s) {
id,
body,
Expand All @@ -317,20 +317,19 @@ def get_updates_for_item_query(board, item, limit):
file_size
},
replies {
id,
body,
creator{
id,
name,
email
},
created_at,
updated_at
body,
creator{
id,
name,
email
},
created_at,
updated_at
}
}
}
}
}
}''' % (board, item, limit)
}''' % (item, limit)

return query

Expand Down Expand Up @@ -371,25 +370,26 @@ def get_tags_query(tags):
def get_board_items_query(board_id: Union[str, int], limit: Optional[int] = None, page: Optional[int] = None) -> str:

raw_params = locals().items()
item_params = gather_params(raw_params, exclusion_list=["board_id"])
item_params = gather_params(raw_params, exclusion_list=["board_id", "item_ids"])
joined_params = ', '.join(item_params)

query = '''query
{
boards(ids: %s) {
query = '''query{
boards(ids: %s){
name
items(%s) {
group {
items_page (){
items(%s) {
group {
id
title
}
id
title
}
id
name
column_values {
id
text
type
value
name
column_values {
id
text
type
value
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion monday/resources/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
update_multiple_column_values_query, mutate_subitem_query, add_file_to_column_query, delete_item_query, \
archive_item_query, move_item_to_group_query


class ItemResource(BaseResource):
def __init__(self, token, headers):
super().__init__(token, headers)
Expand Down
4 changes: 2 additions & 2 deletions monday/resources/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def fetch_updates(self, limit, page=None):
query = get_update_query(limit, page)
return self.client.execute(query)

def fetch_updates_for_item(self, board_id, item_id, limit=100):
query = get_updates_for_item_query(board=board_id, item=item_id, limit=limit)
def fetch_updates_for_item(self, item_id, limit=100):
query = get_updates_for_item_query(item=item_id, limit=limit)
return self.client.execute(query)
3 changes: 1 addition & 2 deletions monday/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from typing import List
from enum import Enum
import json


def monday_json_stringify(value):
Expand All @@ -12,7 +12,6 @@ def monday_json_stringify(value):

return json.dumps(json.dumps(value))


def gather_params(params, exclusion_list: List[str]) -> List[str]:
valid_params: List[str] = []
for param, value in params:
Expand Down

0 comments on commit 62167c1

Please sign in to comment.