Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Search of Pages and / or Database in SearchComponent Currently Doesn't Support Pagination #38

Closed
2 tasks
Nabhag8848 opened this issue Jan 17, 2024 · 7 comments · Fixed by #59
Closed
2 tasks
Labels
bug Something isn't working

Comments

@Nabhag8848
Copy link
Collaborator

What happened?

  • Current Implemenatation doesn't support pagination of Searching pages and/ or databases.
  • Api endpoint of Search Page, Returns maximum of 100 pages
  • https://developers.notion.com/reference/post-search
  • methods searchPages, searchDatabase, SearchPagesandDatabases under NotionSDK, (maybe more) uses this API.

Steps to reproduce

  • Improve methods such a way that it gets all the avaialable pages and / or databases.
  • Check if there is performance issue while doing this.

Relevant ScreenShots

No response

Version

v6.5

What browsers are you seeing the problem on?

Chrome

@Nabhag8848 Nabhag8848 added the bug Something isn't working label Jan 17, 2024
@brf153
Copy link
Contributor

brf153 commented Jan 19, 2024

@Nabhag8848 working on this issue.

@brf153
Copy link
Contributor

brf153 commented Jan 20, 2024

How I Will Implement the Changes:

  1. After reviewing Notion's API guide, I realized that the response allows a maximum of 100 items. If the number of items exceeds 100, the response will contain 'has_more: true' along with a cursor value. To retrieve additional items, we need to pass this cursor value back to Notion's API, either through a query in a GET request or using the body in a POST request.
    Screenshot from 2024-01-20 12-02-06

  2. Consequently, I will implement a mechanism to check 'has_more' in every response. If 'has_more' is true, we will extract the cursor value from the response and send another request, continuing this process until 'has_more' becomes false. Subsequently, we will merge all the responses into one array, which will be passed as the final response for subsequent implementations.

  3. To verify the implementation and address potential performance issues, I will initially set the 'page_size' to 10 and create more than 10 pages in my workspace. Following this, I will send the query and assess its functionality to ensure its effectiveness.

@brf153
Copy link
Contributor

brf153 commented Jan 20, 2024

How I Will Implement the Changes:

  1. After reviewing Notion's API guide, I realized that the response allows a maximum of 100 items. If the number of items exceeds 100, the response will contain 'has_more: true' along with a cursor value. To retrieve additional items, we need to pass this cursor value back to Notion's API, either through a query in a GET request or using the body in a POST request.
    Screenshot from 2024-01-20 12-02-06
  2. Consequently, I will implement a mechanism to check 'has_more' in every response. If 'has_more' is true, we will extract the cursor value from the response and send another request, continuing this process until 'has_more' becomes false. Subsequently, we will merge all the responses into one array, which will be passed as the final response for subsequent implementations.
  3. To verify the implementation and address potential performance issues, I will initially set the 'page_size' to 10 and create more than 10 pages in my workspace. Following this, I will send the query and assess its functionality to ensure its effectiveness.

@Nabhag8848 Could you please review this and advise if I should proceed with this approach?

@Nabhag8848
Copy link
Collaborator Author

Nabhag8848 commented Jan 21, 2024

How I Will Implement the Changes:

  1. After reviewing Notion's API guide, I realized that the response allows a maximum of 100 items. If the number of items exceeds 100, the response will contain 'has_more: true' along with a cursor value. To retrieve additional items, we need to pass this cursor value back to Notion's API, either through a query in a GET request or using the body in a POST request.
    Screenshot from 2024-01-20 12-02-06
  2. Consequently, I will implement a mechanism to check 'has_more' in every response. If 'has_more' is true, we will extract the cursor value from the response and send another request, continuing this process until 'has_more' becomes false. Subsequently, we will merge all the responses into one array, which will be passed as the final response for subsequent implementations.
  3. To verify the implementation and address potential performance issues, I will initially set the 'page_size' to 10 and create more than 10 pages in my workspace. Following this, I will send the query and assess its functionality to ensure its effectiveness.
  • Overall you got the implementation but check by setting page_size to 100 itself, cause larger page_size (>10) is proved to work feasibly. Also note that lesser the number of page_size more the Network request. thus we will try to make minimum network request and get maximum page a each request, I believe will involve recursion concept.

  • Create around 300 page with api with random names.

  • Create around 150 pages with api which is part of record / db, Note: You might be aware every Notion Table Record / Row we have is also a page.

  • Create around 150 DB with Random Properties with api

and Try to Fetch it using /search endpoint.

  1. Search only Pages.
  2. Search only Databases.
  3. Search Pages and Databases both at a time.

See all this cases, you will have a chance to explore api.

@brf153
Copy link
Contributor

brf153 commented Jan 21, 2024

@Nabhag8848 how will I check with page_size 100? Will I have to make more than 100 pages to check this?

@Nabhag8848
Copy link
Collaborator Author

@Nabhag8848 how will I check with page_size 100? Will I have to make more than 100 pages to check this?

Edited the Message. Yep Use Api to create it.

@brf153
Copy link
Contributor

brf153 commented Jan 21, 2024

@Nabhag8848 oki I will do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants