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
16 changes: 0 additions & 16 deletions api/models/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,6 @@ def data_source_info_dict(self) -> dict[str, Any]:
return data_source_info_dict
return {}

@property
def data_source_detail_dict(self) -> dict[str, Any]:
return self.get_data_source_detail_dict(session=db.session())

def get_data_source_detail_dict(self, *, session: Session) -> dict[str, Any]:
if self.data_source_info:
if self.data_source_type == "upload_file":
Expand Down Expand Up @@ -665,10 +661,6 @@ def get_dataset_process_rule(self, *, session: Session) -> "DatasetProcessRule |
return session.get(DatasetProcessRule, self.dataset_process_rule_id)
return None

@property
def dataset(self) -> Dataset | None:
return self.get_dataset(session=db.session())

def get_dataset(self, *, session: Session) -> Dataset | None:
"""Load the owning dataset with the caller-owned database session."""
return session.get(Dataset, self.dataset_id)
Expand All @@ -694,10 +686,6 @@ def get_hit_count(self, *, session: Session) -> int:
or 0
)

@property
def uploader(self):
return self.get_uploader(session=db.session())

def get_uploader(self, *, session: Session) -> str | None:
user = session.scalar(select(Account).where(Account.id == self.created_by))
return user.name if user else None
Expand All @@ -710,10 +698,6 @@ def upload_date(self):
def last_update_date(self):
return self.updated_at

@property
def doc_metadata_details(self) -> list[DocMetadataDetailItem] | None:
return self.get_doc_metadata_details(session=db.session())

def get_doc_metadata_details(self, *, session: Session) -> list[DocMetadataDetailItem] | None:
if self.doc_metadata:
document_metadatas = session.scalars(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import json
from typing import Literal, NotRequired, TypedDict
from unittest.mock import MagicMock

from models.dataset import Document

Expand Down Expand Up @@ -116,7 +117,7 @@ def test_notion_and_website_crawl_data_source_detail(self):
)

# data_source_detail_dict should return raw data for notion_import
detail_result = document.data_source_detail_dict
detail_result = document.get_data_source_detail_dict(session=MagicMock())
assert detail_result == notion_data

# Test website_crawl
Expand All @@ -127,7 +128,7 @@ def test_notion_and_website_crawl_data_source_detail(self):
)

# data_source_detail_dict should return raw data for website_crawl
detail_result = document.data_source_detail_dict
detail_result = document.get_data_source_detail_dict(session=MagicMock())
assert detail_result == website_data

def test_local_file_data_source_detail_dict_without_db(self):
Expand All @@ -139,5 +140,5 @@ def test_local_file_data_source_detail_dict_without_db(self):
)

# Should return empty dict for local_file type (handled in the model)
detail_result = document.data_source_detail_dict
detail_result = document.get_data_source_detail_dict(session=MagicMock())
assert detail_result == {}
Loading