kevinjalbert / notion-toolbox

This is a collection of Notion tools that work in tandem together.
https://kevinjalbert.com/consolidating-notion-projects-into-notion-toolbox/
MIT License
687 stars 59 forks source link

Issue getting the current day #6

Closed CKPleiser closed 5 years ago

CKPleiser commented 5 years ago

Everything is working as expected, except I can't get the current day. I followed the tutorial and have my days underneath the current week. I also experimented by changing the array index, but ColumnBlocks and Blocks are not iterable:

image

I assume this has to do with this: image

My current Notion looks like this: image

I'm a first-time Notion user and don't quite understand the structure yet. I read through the Notion API wrapper, but can't seem to get it to work. Getting the current week, however, works like a charm.

kevinjalbert commented 5 years ago

👋 My initial thoughts are that the week template page has undergone some rearrangement of blocks on your side. The unfortunate part of this project is that it is heavily dependant on structure.

We can work though this, try this:

diff --git a/src/get_current_day.py b/src/get_current_day.py
index 325da70..2a7ad19 100755
--- a/src/get_current_day.py
+++ b/src/get_current_day.py
@@ -7,6 +7,9 @@ from utils import app_url

 try:
+    print(notion_api.current_week().children)
+    print(notion_api.current_week().children[1].children)
+    print(notion_api.current_week().children[1].children[1].children)
     print(app_url(notion_api.current_day().get_browseable_url()))
 except Exception as e:
     # Print out nothing on STDOUT (missing value means means operation was unsuccessful)

You can probably view that in the alfred workflow debugger, but you can also just call python3 src/get_current_day.py in the project as well. This should spit out something like the following:

[
  <BreadcrumbBlock (id='40ce8d79-ad49-4ffc-9d0c-c84ddcc46d7e')>,
  <ColumnListBlock (id='2d74c2ce-f46b-48c1-b3f2-308741cee53a')>,
  <Block (id='699dcd5a-d78c-42f8-a694-0162e8705dab', type='copy_indicator')>,
  <Block (id='703fe0ee-592d-4957-b8a6-266637988a4c', type='copy_indicator')>,
  <Block (id='fd0a58d8-c4b8-486d-a45e-fbacabcf89b3', type='copy_indicator')>,
  <Block (id='3c19bc31-0887-4f54-9be3-34cd9984e9d6', type='copy_indicator')>,
  <CollectionViewBlock (id='28f554dd-0c87-43be-9ce1-e199d75c5436', title='🚦 2019 > Week 39 >  Lights', collection=<Collection (id='b17b3791-c74f-4af9-a848-59a80480637d')>)>,
  <HeaderBlock (id='3807fd2a-1b42-4191-843d-4c10c3a02ae3', title="Week's Achievements")>,
  <CollectionViewBlock (id='ad17251e-2f59-4da5-b952-8aea2362ad2a', title='Wins', collection=<Collection (id='d37bd813-2c89-4dea-aea7-b677ece499a5')>)>,
  <CollectionViewBlock (id='d2c7152a-50f9-44bf-a42c-5161bb7f86cf', title='Tasks', collection=<Collection (id='096950d6-fb62-43a7-bc2e-3cdfeb0133de')>)>,
  <HeaderBlock (id='20ae5d70-3ea5-4b41-a0e4-5b2a994d9e8a', title='Weekly Review')>,
  <SubheaderBlock (id='30d99327-d561-4b98-80bb-cabc80642053', title='Lights (Aim for 5-6 *Yes,* adjust if outside of this)')>,
  <BulletedListBlock (id='6c06c69f-6677-46a9-8d5e-d855c3805242', title='_Reflection_on_objectives_what_changes_for_next_week_')>,
  <SubheaderBlock (id='592c33e1-1712-493d-bcf9-7bf97acc4737', title="RescueTime (make link to week's dashboard)")>,
  <TextBlock (id='acd6b915-2bf7-4482-8cab-c67cf0d0dbc0', title='_Screenshot_of_dashboard_')>,
  <TextBlock (id='e0bff09a-8a9a-4369-9307-13b01c9c1896')>,
]
[
  <ColumnBlock (id='34cc0644-eaff-4220-bac6-1440b0ad62a0')>,
  <ColumnBlock (id='9aefe46a-0699-4505-8ef9-938cf1f4fa6e')>,
]
[
  <HeaderBlock (id='1e90dfcc-a415-4296-9256-8c07e01caf85', title='Days')>,
  <PageBlock (id='abf79efa-1e35-4562-bb8c-c87dfcca0b15', title='September 22 (Sunday)')>,
  <PageBlock (id='752dd11c-3661-439f-a006-81ab83c65643', title='September 23 (Monday)')>,
  <PageBlock (id='8b07b683-4471-481a-b364-0aac1ec5bd20', title='September 24 (Tuesday)')>,
  <PageBlock (id='6cb558c6-37a2-4111-8440-1ea1b0140700', title='September 25 (Wednesday)')>,
  <PageBlock (id='f7b7c4cd-e5d9-4d42-b4e1-b94fd2b76963', title='September 26 (Thursday)')>,
  <PageBlock (id='e4db9115-0386-420f-afad-917dbfa823b8', title='September 27 (Friday)')>,
  <PageBlock (id='6446f5d9-3832-4174-8e0f-2300faca2833', title='September 28 (Saturday)')>,
]

It is likely that somewhere we have some different blocks in place.

We are drilling in with each call: -> <ColumnListBlock (id='2d74c2ce-f46b-48c1-b3f2-308741cee53a')> The (quick link + days) column list block -> <ColumnBlock (id='9aefe46a-0699-4505-8ef9-938cf1f4fa6e')> The days column block -> All the day pages

Let me know if that helps at all.

CKPleiser commented 5 years ago

Hi Kevin,

Thanks so much for it, that really helped and resolved the issue. I had to re-arrange some of the columns in my week template and now it works like a charm.

This workflow is amazing and saves so much time in the long run.

Well done!