|
12 | 12 | from apps.activity_flows.domain.flow_create import FlowCreate, FlowItemCreate |
13 | 13 | from apps.activity_flows.service.flow import FlowService |
14 | 14 | from apps.answers.crud.answers import AnswersCRUD |
| 15 | +from apps.answers.deps.preprocess_arbitrary import get_arbitrary_info |
15 | 16 | from apps.applets.crud import ( |
16 | 17 | AppletHistoriesCRUD, |
17 | 18 | AppletsCRUD, |
|
58 | 59 | from apps.workspaces.errors import AppletEncryptionUpdateDenied |
59 | 60 | from apps.workspaces.service.user_applet_access import UserAppletAccessService |
60 | 61 | from config import settings |
| 62 | +from infrastructure.database import session_manager |
61 | 63 |
|
62 | 64 | __all__ = [ |
63 | 65 | "AppletService", |
@@ -827,9 +829,26 @@ async def set_data_retention( |
827 | 829 | applet_id, data_retention |
828 | 830 | ) |
829 | 831 | if data_retention.retention != DataRetention.INDEFINITELY: |
830 | | - await AnswersCRUD(self.session).removing_outdated_answers( |
831 | | - applet_id, data_retention.period or 1, data_retention.retention |
832 | | - ) |
| 832 | + arb_uri = await get_arbitrary_info(applet_id, self.session) |
| 833 | + if arb_uri: |
| 834 | + arb_session_maker = session_manager.get_session(arb_uri) |
| 835 | + try: |
| 836 | + async with arb_session_maker() as arb_session: |
| 837 | + await AnswersCRUD( |
| 838 | + arb_session |
| 839 | + ).removing_outdated_answers( |
| 840 | + applet_id, |
| 841 | + data_retention.period or 10**10, |
| 842 | + data_retention.retention, |
| 843 | + ) |
| 844 | + finally: |
| 845 | + await arb_session_maker.remove() |
| 846 | + else: |
| 847 | + await AnswersCRUD(self.session).removing_outdated_answers( |
| 848 | + applet_id, |
| 849 | + data_retention.period or 10**10, |
| 850 | + data_retention.retention, |
| 851 | + ) |
833 | 852 |
|
834 | 853 | async def get_full_applet(self, applet_id: uuid.UUID) -> AppletFull: |
835 | 854 | schema = await AppletsCRUD(self.session).get_by_id(applet_id) |
|
0 commit comments