Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 16 additions & 1 deletion business_objects/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from . import general, organization
from .. import enums
from ..session import session
from typing import Dict, List, Any, Optional, Union
from typing import Dict, List, Any, Optional, Union, Iterable
from ..util import prevent_sql_injection


Expand Down Expand Up @@ -305,6 +305,21 @@ def remove(comment_id: str, with_commit: bool = False) -> None:
general.flush_or_commit(with_commit)


def delete_by_type_and_xfkey(
project_id: str,
xfkeys: Iterable[str],
xftype: enums.CommentCategory,
with_commit: bool = False,
) -> None:

session.query(CommentData).filter(
CommentData.project_id == project_id,
CommentData.xfkey.in_(xfkeys),
CommentData.xftype == xftype.value,
).delete()
general.flush_or_commit(with_commit)


def get_unique_comments_keys_for(
xftype: enums.CommentCategory, project_id: Optional[str] = None
) -> List[str]:
Expand Down
12 changes: 12 additions & 0 deletions business_objects/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,18 @@ def delete(project_id: str, record_id: str, with_commit: bool = False) -> None:
general.flush_or_commit(with_commit)


def delete_many(
project_id: str, record_ids: Iterable[str], with_commit: bool = False
) -> int:
res = (
session.query(Record)
.filter(Record.project_id == project_id, Record.id.in_(record_ids))
.delete()
)
general.flush_or_commit(with_commit)
return res


def delete_all(project_id: str, with_commit: bool = False) -> None:
session.query(Record).filter(Record.project_id == project_id).delete()
general.flush_or_commit(with_commit)
Expand Down