Skip to content

Commit bee30a7

Browse files
committed
Merge branch 'master' of github.com:splitbee/notion-api-worker into fix-content
2 parents d0f9146 + 8b93b03 commit bee30a7

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/api/notion.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,24 @@ export const fetchPageById = async (pageId: string, notionToken?: string) => {
5353
};
5454

5555
const queryCollectionBody = {
56-
query: { aggregations: [{ property: "title", aggregator: "count" }] },
5756
loader: {
58-
type: "table",
59-
limit: 999,
57+
type: "reducer",
58+
reducers: {
59+
collection_group_results: {
60+
type: "results",
61+
limit: 999,
62+
loadContentCover: true,
63+
},
64+
"table:uncategorized:title:count": {
65+
type: "aggregation",
66+
aggregation: {
67+
property: "title",
68+
aggregator: "count",
69+
},
70+
},
71+
},
6072
searchQuery: "",
6173
userTimeZone: "Europe/Vienna",
62-
userLocale: "en",
63-
loadContentCover: true,
6474
},
6575
};
6676

@@ -72,12 +82,17 @@ export const fetchTableData = async (
7282
const table = await fetchNotionData<CollectionData>({
7383
resource: "queryCollection",
7484
body: {
75-
collectionId,
76-
collectionViewId,
85+
collection: {
86+
id: collectionId,
87+
},
88+
collectionView: {
89+
id: collectionViewId,
90+
},
7791
...queryCollectionBody,
7892
},
7993
notionToken,
8094
});
95+
8196
return table;
8297
};
8398

src/api/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ export interface CollectionData {
165165
};
166166
};
167167
result: {
168-
blockIds: string[];
168+
reducerResults: {
169+
collection_group_results: { blockIds: string[] };
170+
};
169171
};
170172
}
171173

src/routes/table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const getTableData = async (
2323
const collectionRows = collection.value.schema;
2424
const collectionColKeys = Object.keys(collectionRows);
2525

26-
const tableArr: RowType[] = table.result.blockIds.map(
26+
const tableArr: RowType[] = table.result.reducerResults.collection_group_results.blockIds.map(
2727
(id: string) => table.recordMap.block[id]
2828
);
2929

0 commit comments

Comments
 (0)