@@ -1069,6 +1069,13 @@ def _deserialize_link(self, doc: JourneyLinkAssociationDocument) -> JourneyLink:
10691069 merge_node_id = JourneyNodeId (doc ["merge_node_id" ]),
10701070 )
10711071
1072+ async def _touch_journey_last_modified (self , journey_id : JourneyId ) -> None :
1073+ """Update the journey's last_modified timestamp."""
1074+ await self ._collection .update_one (
1075+ filters = {"id" : {"$eq" : journey_id }},
1076+ params = {"last_modified" : datetime .now (timezone .utc ).isoformat ()},
1077+ )
1078+
10721079 @staticmethod
10731080 def assemble_content (
10741081 title : str ,
@@ -1519,6 +1526,8 @@ async def create_node(
15191526 document = self ._serialize_node (node , journey_id )
15201527 )
15211528
1529+ await self ._touch_journey_last_modified (journey_id )
1530+
15221531 return node
15231532
15241533 @override
@@ -1566,6 +1575,8 @@ async def update_node(
15661575 params = cast (JourneyNodeAssociationDocument , to_json_dict (updated )),
15671576 )
15681577
1578+ await self ._touch_journey_last_modified (doc ["journey_id" ])
1579+
15691580 assert result .updated_document
15701581
15711582 return self ._deserialize_node (result .updated_document )
@@ -1583,7 +1594,9 @@ async def delete_node(
15831594 if not node_doc :
15841595 raise ItemNotFoundError (item_id = UniqueId (node_id ))
15851596
1586- edges = await self .list_edges (journey_id = node_doc ["journey_id" ], node_id = node_id )
1597+ journey_id = node_doc ["journey_id" ]
1598+
1599+ edges = await self .list_edges (journey_id = journey_id , node_id = node_id )
15871600
15881601 for edge in edges :
15891602 await self .delete_edge (edge .id )
@@ -1592,6 +1605,8 @@ async def delete_node(
15921605 filters = {"node_id" : {"$eq" : node_id }}
15931606 )
15941607
1608+ await self ._touch_journey_last_modified (journey_id )
1609+
15951610 if result .deleted_count == 0 :
15961611 raise ItemNotFoundError (item_id = UniqueId (node_id ))
15971612
@@ -1690,7 +1705,10 @@ async def set_journey_metadata(
16901705
16911706 result = await self ._collection .update_one (
16921707 filters = {"id" : {"$eq" : journey_id }},
1693- params = {"metadata" : updated_metadata },
1708+ params = {
1709+ "metadata" : updated_metadata ,
1710+ "last_modified" : datetime .now (timezone .utc ).isoformat (),
1711+ },
16941712 )
16951713
16961714 assert result .updated_document
@@ -1713,7 +1731,10 @@ async def unset_journey_metadata(
17131731
17141732 result = await self ._collection .update_one (
17151733 filters = {"id" : {"$eq" : journey_id }},
1716- params = {"metadata" : updated_metadata },
1734+ params = {
1735+ "metadata" : updated_metadata ,
1736+ "last_modified" : datetime .now (timezone .utc ).isoformat (),
1737+ },
17171738 )
17181739
17191740 assert result .updated_document
@@ -1734,7 +1755,10 @@ async def set_node_properties(
17341755
17351756 result = await self ._collection .update_one (
17361757 filters = {"id" : {"$eq" : journey_id }},
1737- params = {"node_properties" : node_properties },
1758+ params = {
1759+ "node_properties" : node_properties ,
1760+ "last_modified" : datetime .now (timezone .utc ).isoformat (),
1761+ },
17381762 )
17391763
17401764 assert result .updated_document
@@ -1765,6 +1789,8 @@ async def create_edge(
17651789 document = self ._serialize_edge (edge , journey_id )
17661790 )
17671791
1792+ await self ._touch_journey_last_modified (journey_id )
1793+
17681794 return edge
17691795
17701796 @override
@@ -1799,6 +1825,8 @@ async def update_edge(
17991825 params = cast (JourneyEdgeAssociationDocument , to_json_dict (updated )),
18001826 )
18011827
1828+ await self ._touch_journey_last_modified (doc ["journey_id" ])
1829+
18021830 assert result .updated_document
18031831
18041832 return self ._deserialize_edge (result .updated_document )
@@ -1836,10 +1864,15 @@ async def delete_edge(
18361864 edge_id : JourneyEdgeId ,
18371865 ) -> None :
18381866 async with self ._lock .writer_lock :
1867+ edge_doc = await self ._edge_association_collection .find_one ({"id" : {"$eq" : edge_id }})
1868+
18391869 result = await self ._edge_association_collection .delete_one (
18401870 filters = {"id" : {"$eq" : edge_id }}
18411871 )
18421872
1873+ if result .deleted_count > 0 and edge_doc :
1874+ await self ._touch_journey_last_modified (edge_doc ["journey_id" ])
1875+
18431876 if result .deleted_count == 0 :
18441877 raise ItemNotFoundError (item_id = UniqueId (edge_id ))
18451878
@@ -2033,6 +2066,7 @@ async def create_link(
20332066
20342067 async with self ._lock .writer_lock :
20352068 await self ._link_association_collection .insert_one (document = self ._serialize_link (link ))
2069+ await self ._touch_journey_last_modified (journey_id )
20362070
20372071 return link
20382072
@@ -2074,7 +2108,7 @@ async def delete_link(
20742108
20752109 link = self ._deserialize_link (link_doc )
20762110
2077- # Delete the merge fork node
2111+ # Delete the merge fork node (also touches last_modified via delete_node)
20782112 await self .delete_node (link .merge_node_id )
20792113
20802114 async with self ._lock .writer_lock :
0 commit comments