Skip to content

Commit af24f27

Browse files
committed
feat(notes): read/write the last note id
a simple UTF-8 text file
1 parent b0b4444 commit af24f27

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ qr_codes/*.png
55
!qr_codes/calitp.org.png
66
**/data/*.*
77
!data/*.py
8+
last_note_id

hubspot/notes.ipynb

+28
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
"outputs": [],
3131
"source": [
3232
"import os\n",
33+
"from pathlib import Path\n",
3334
"\n",
3435
"from hubspot import HubSpot\n",
3536
"\n",
3637
"from data.utils import hubspot_to_df, write_json_records\n",
3738
"\n",
3839
"\n",
3940
"ACCESS_TOKEN = os.environ[\"HUBSPOT_ACCESS_TOKEN\"]\n",
41+
"LAST_NOTE_PATH = Path(\"last_note_id\")\n",
4042
"PAGE_SIZE = 10\n",
4143
"\n",
4244
"PROPERTIES = [\"hs_created_by\", \"hs_createdate\", \"hs_note_body\"]\n",
@@ -46,6 +48,32 @@
4648
"hubspot = HubSpot(access_token=ACCESS_TOKEN)"
4749
]
4850
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"metadata": {},
55+
"outputs": [],
56+
"source": [
57+
"def get_last_note_id():\n",
58+
" try:\n",
59+
" return LAST_NOTE_PATH.read_text(encoding=\"utf-8\").strip()\n",
60+
" except FileNotFoundError:\n",
61+
" return None\n",
62+
"\n",
63+
"\n",
64+
"def update_last_note_id(last_note_id):\n",
65+
" LAST_NOTE_PATH.write_text(last_note_id, encoding=\"utf-8\")"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": null,
71+
"metadata": {},
72+
"outputs": [],
73+
"source": [
74+
"LAST_NOTE_PATH.unlink(missing_ok=True)"
75+
]
76+
},
4977
{
5078
"cell_type": "code",
5179
"execution_count": null,

0 commit comments

Comments
 (0)