Skip to content
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

Custom cleanup conversations and files by org #275

Merged
merged 9 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""add conversation and file lifespan

Revision ID: eb5ecbee5090
Revises: 7aa933ec5de9
Create Date: 2024-11-26 11:03:23.883173

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "eb5ecbee5090"
down_revision = "7aa933ec5de9"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"organization",
sa.Column("conversation_lifespan_days", sa.Integer(), nullable=True),
)
op.add_column(
"organization",
sa.Column(
"file_lifespan_days", sa.Integer(), nullable=True, server_default="14"
),
)
op.drop_column("organization", "gdpr_compliant")
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"organization",
sa.Column("gdpr_compliant", sa.BOOLEAN(), autoincrement=False, nullable=True),
)
op.drop_column("organization", "file_lifespan_days")
op.drop_column("organization", "conversation_lifespan_days")
# ### end Alembic commands ###
18 changes: 1 addition & 17 deletions controller/organization/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@
from submodules.model.business_objects import organization, general, user
from submodules.model.exceptions import EntityAlreadyExistsException
from submodules.model.models import Organization, User
from util import notification
from controller.auth import kratos
from submodules.model.util import sql_alchemy_to_dict
from submodules.s3 import controller as s3

USER_INFO_WHITELIST = {"id", "role"}
ORGANIZATION_WHITELIST = {
"id",
"name",
"max_rows",
"max_cols",
"max_char_count",
"gdpr_compliant",
}
ORGANIZATION_WHITELIST = {"id", "name", "max_rows", "max_cols", "max_char_count"}


def change_organization(org_id: str, changes: Dict[str, Any]) -> None:
Expand All @@ -28,7 +20,6 @@ def change_organization(org_id: str, changes: Dict[str, Any]) -> None:
for k in changes:

if hasattr(org, k):
__check_notification(org_id, k, changes[k])
setattr(org, k, changes[k])
else:
raise ValueError(f"Organization has no attribute {k}")
Expand Down Expand Up @@ -98,10 +89,3 @@ def get_overview_stats(org_id: str) -> List[Dict[str, Union[str, int]]]:
if org_id is None:
return []
return organization.get_organization_overview_stats(org_id)


def __check_notification(org_id: str, key: str, value: Any):
if key in ["gdpr_compliant"]:
notification.send_organization_update(
None, f"gdpr_compliant:{value}", True, org_id
)
4 changes: 2 additions & 2 deletions fast_api/routes/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from controller.user import manager as user_manager

from fast_api.routes.client_response import get_silent_success, pack_json_result
from submodules.model import events
from submodules.model.business_objects import organization, user
from submodules.model.util import sql_alchemy_to_dict
from util import notification
Expand Down Expand Up @@ -221,8 +220,9 @@ def get_all_organizations(request: Request):
"maxRows": org.max_rows,
"maxCols": org.max_cols,
"maxCharCount": org.max_char_count,
"gdprCompliant": org.gdpr_compliant,
"logAdminRequests": org.log_admin_requests,
"conversationLifespanDays": org.conversation_lifespan_days,
LennartSchmidtKern marked this conversation as resolved.
Show resolved Hide resolved
"fileLifespanDays": org.file_lifespan_days,
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion submodules/model