notion-cascade-insert 0.0.4__py3-none-any.whl → 0.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.3"
1
+ __version__ = "0.0.4"
2
2
  """Notion API wrapper for easy database cascade insert (one-to-many) automation"""
3
3
 
4
4
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/index.ipynb.
@@ -9,8 +9,12 @@ d = { 'settings': { 'branch': 'main',
9
9
  'notion_cascade_insert/core.py'),
10
10
  'notion_cascade_insert.core.AutoLogger.__init__': ( 'core.html#autologger.__init__',
11
11
  'notion_cascade_insert/core.py'),
12
+ 'notion_cascade_insert.core.AutoLogger.handle_update': ( 'core.html#autologger.handle_update',
13
+ 'notion_cascade_insert/core.py'),
12
14
  'notion_cascade_insert.core.AutoLogger.process': ( 'core.html#autologger.process',
13
15
  'notion_cascade_insert/core.py'),
16
+ 'notion_cascade_insert.core.AutoLogger.undo_all': ( 'core.html#autologger.undo_all',
17
+ 'notion_cascade_insert/core.py'),
14
18
  'notion_cascade_insert.core.Database': ('core.html#database', 'notion_cascade_insert/core.py'),
15
19
  'notion_cascade_insert.core.Database.__init__': ( 'core.html#database.__init__',
16
20
  'notion_cascade_insert/core.py'),
@@ -29,6 +33,8 @@ d = { 'settings': { 'branch': 'main',
29
33
  'notion_cascade_insert/core.py'),
30
34
  'notion_cascade_insert.core.LogDB.create_entry': ( 'core.html#logdb.create_entry',
31
35
  'notion_cascade_insert/core.py'),
36
+ 'notion_cascade_insert.core.LogDB.get_entries_for_trigger': ( 'core.html#logdb.get_entries_for_trigger',
37
+ 'notion_cascade_insert/core.py'),
32
38
  'notion_cascade_insert.core.TriggerDB': ( 'core.html#triggerdb',
33
39
  'notion_cascade_insert/core.py'),
34
40
  'notion_cascade_insert.core.TriggerDB.__init__': ( 'core.html#triggerdb.__init__',
@@ -165,3 +165,26 @@ class AutoLogger:
165
165
  if not items: return "No items found in junction"
166
166
  for item_id, amt in items.items(): self.log_db.create_entry(item_id, self.multiplier * qty * amt, page_id, reason)
167
167
  return f"Logged {len(items)} items"
168
+
169
+ # %% ../nbs/00_core.ipynb #da5abd7e
170
+ @patch
171
+ def get_entries_for_trigger(self:LogDB, trigger_page_id):
172
+ "Find all log entries linked to a specific trigger page"
173
+ results = self.notion.databases.query(database_id=self.db_id, filter={"property": self.trigger_prop, "relation": {"contains": trigger_page_id}})
174
+ return [(p['id'], p['properties'][self.item_prop]['relation'][0]['id'], p['properties'][self.amt_prop]['number']) for p in results['results']]
175
+
176
+ @patch
177
+ def undo_all(self:AutoLogger, page_id, reason='Undo Changes'):
178
+ "Reverse all existing log entries for a trigger page"
179
+ entries = self.log_db.get_entries_for_trigger(page_id)
180
+ if not entries: return "No entries to undo"
181
+ for _, item_id, amt in entries: self.log_db.create_entry(item_id, -amt, page_id, reason)
182
+ return f"Undone {len(entries)} entries"
183
+
184
+ @patch
185
+ def handle_update(self:AutoLogger, page_id, reason='Update Production'):
186
+ "Handle trigger page updates by undoing and reprocessing"
187
+ status, _, _ = self.trigger_db.get_page_data(page_id)
188
+ self.undo_all(page_id, reason)
189
+ if status == self.trigger_status: return self.process(page_id, reason)
190
+ return f"Undone entries (status now {status})"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notion_cascade_insert
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Cascade inserting for Notion Database Automation (as log)
5
5
  Home-page: https://github.com/amezaikupan/notion_cascade_insert
6
6
  Author: TN
@@ -0,0 +1,10 @@
1
+ notion_cascade_insert/__init__.py,sha256=UOJcVl2OK2kvj_6VbbjMftGdtixim8EJ7fbRVbUByJI,322
2
+ notion_cascade_insert/_modidx.py,sha256=VAD0TLHCIbcd5a8Fgr378dXyw_shDAl2ss-GM4_4LMc,6140
3
+ notion_cascade_insert/core.py,sha256=8nPi-nGtzHZ4xKmb62wKlIPKsahJtTPE8u5Ilrq_0lY,8273
4
+ notion_cascade_insert/webhook.py,sha256=myE6iRY232Zd2uBSfuepPcIPm4mopEYWmFzvfaWxF30,1214
5
+ notion_cascade_insert-0.0.5.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
6
+ notion_cascade_insert-0.0.5.dist-info/METADATA,sha256=G2tsRYM0gbMBuLEXmXEvkwVSSQKWqQb4Z_MNLDQP5po,3724
7
+ notion_cascade_insert-0.0.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
8
+ notion_cascade_insert-0.0.5.dist-info/entry_points.txt,sha256=XqKv0P7bGQlZ7SqZcyTdvIaQJI8GlMHtcJP9NPOhQbA,64
9
+ notion_cascade_insert-0.0.5.dist-info/top_level.txt,sha256=XRld1ok2pAh3DC9o3ZByqlORHGblJMVMOjE0pQRROE4,22
10
+ notion_cascade_insert-0.0.5.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- notion_cascade_insert/__init__.py,sha256=auXNGZG-UuY84e9PtdBQpmFqSBmZvpdPH-yqwWW6UfY,322
2
- notion_cascade_insert/_modidx.py,sha256=V5jZmpu2PTUn0MHd9Vr0CQPSwsfMXj9OPZO4ILK6fLU,5318
3
- notion_cascade_insert/core.py,sha256=qSzfRMoVXgOwyY5UcpiGDR1iLXodPCNMg0V2IPT3810,7079
4
- notion_cascade_insert/webhook.py,sha256=myE6iRY232Zd2uBSfuepPcIPm4mopEYWmFzvfaWxF30,1214
5
- notion_cascade_insert-0.0.4.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
6
- notion_cascade_insert-0.0.4.dist-info/METADATA,sha256=9vJmMS83vTW5yW5t48ekv-zgMpEP6VXa_2DsUOQpls8,3724
7
- notion_cascade_insert-0.0.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
8
- notion_cascade_insert-0.0.4.dist-info/entry_points.txt,sha256=XqKv0P7bGQlZ7SqZcyTdvIaQJI8GlMHtcJP9NPOhQbA,64
9
- notion_cascade_insert-0.0.4.dist-info/top_level.txt,sha256=XRld1ok2pAh3DC9o3ZByqlORHGblJMVMOjE0pQRROE4,22
10
- notion_cascade_insert-0.0.4.dist-info/RECORD,,