I'm trying to create some Notion API integrations to help my team forecast availability for staffing.
I am writing a function that should count all the times a particular user is mentioned in the people
property of a database child page by using the people
filter type.
Here's my code:
async function getUserAssignmentCount(database, user) {
const response = await notion.databases.query({
database_id: database.id,
filter: {
"property": "People",
"people": {
"contains": user.id,
},
},
});
return Object.keys(response).length;
}
For a reason I don't quite understand, this function simply returns 4
for every single user. A quick look at the API docs for the people filter property shows that you can't currently filter for people
properties using the people
filter…so…idk??
Can anyone think of a way to achieve this, either via something undocumented in the API or with some hacky way of getting all the user IDs from a database people
property?
Thanks <3