Skip to content

Custom cleanup conversations and files by org #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 28, 2024
14 changes: 14 additions & 0 deletions cognition_objects/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ def get(project_id: str, conversation_id: str) -> CognitionConversation:
)


def get_all_with_org() -> List[CognitionConversation]:
query = """
SELECT
cc.*,
cp.organization_id
FROM
cognition.conversation cc
JOIN
cognition.project cp
ON
cc.project_id = cp.id;"""
return general.execute_all(query)


def get_scoped(project_id: str, conversation_id: str, user_id) -> CognitionConversation:
return (
session.query(CognitionConversation)
Expand Down
4 changes: 2 additions & 2 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class Organization(Base):
# database entry
is_paying = Column(Boolean, default=False)
created_at = Column(DateTime, default=sql.func.now())
gdpr_compliant = Column(Boolean, default=False)

projects = parent_to_child_relationship(
Tablenames.ORGANIZATION,
Tablenames.PROJECT,
Expand All @@ -156,6 +154,8 @@ class Organization(Base):

# designed as opt out to ensure "forgotten" doesn't result in issues
log_admin_requests = Column(String, default=AdminLogLevel.NO_GET.value)
conversation_lifespan_days = Column(Integer)
file_lifespan_days = Column(Integer, default=14)


class User(Base):
Expand Down