Skip to content

Commit d117ccf

Browse files
committed
More refactoring and fixes
1 parent 107a644 commit d117ccf

File tree

4 files changed

+410
-385
lines changed

4 files changed

+410
-385
lines changed
Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
"""DatabaseBase class for managing database operations"""
2+
13
import uuid
24
from abc import ABC, abstractmethod
3-
from datetime import datetime
4-
from enum import Enum
55
from typing import Dict, List, Optional
66

77
from semantic_kernel.contents import AuthorRole
88

9-
from common.logger.app_logger import AppLogger
10-
from common.models.api import BatchRecord, FileRecord, LogType, ProcessStatus
9+
from common.models.api import BatchRecord, FileRecord, LogType
1110
from sql_agents.helpers.models import AgentType
1211

1312

@@ -17,54 +16,44 @@ class DatabaseBase(ABC):
1716
@abstractmethod
1817
async def initialize_cosmos(self) -> None:
1918
"""Initialize the cosmosdb client and create container if needed"""
20-
pass
2119

2220
@abstractmethod
2321
async def create_batch(self, user_id: str, batch_id: uuid.UUID) -> BatchRecord:
2422
"""Create a new conversion batch"""
25-
pass
2623

2724
@abstractmethod
2825
async def get_file_logs(self, file_id: str) -> Dict:
2926
"""Retrieve all logs for a file"""
30-
pass
3127

3228
@abstractmethod
3329
async def get_batch_from_id(self, batch_id: str) -> Dict:
3430
"""Retrieve all logs for a file"""
35-
pass
3631

3732
@abstractmethod
3833
async def get_batch_files(self, batch_id: str) -> List[Dict]:
3934
"""Retrieve all files for a batch"""
40-
pass
4135

4236
@abstractmethod
4337
async def delete_file_logs(self, file_id: str) -> None:
4438
"""Delete all logs for a file"""
45-
pass
4639

4740
@abstractmethod
4841
async def get_user_batches(self, user_id: str) -> Dict:
4942
"""Retrieve all batches for a user"""
50-
pass
5143

5244
@abstractmethod
5345
async def add_file(
5446
self, batch_id: uuid.UUID, file_id: uuid.UUID, file_name: str, storage_path: str
5547
) -> FileRecord:
5648
"""Add a file entry to the database"""
57-
pass
5849

5950
@abstractmethod
6051
async def get_batch(self, user_id: str, batch_id: str) -> Optional[Dict]:
6152
"""Retrieve a batch and its associated files"""
62-
pass
6353

6454
@abstractmethod
6555
async def get_file(self, file_id: str) -> Optional[Dict]:
6656
"""Retrieve a file entry along with its logs"""
67-
pass
6857

6958
@abstractmethod
7059
async def add_file_log(
@@ -77,38 +66,31 @@ async def add_file_log(
7766
author_role: AuthorRole,
7867
) -> None:
7968
"""Log a file status update"""
80-
pass
8169

8270
@abstractmethod
8371
async def update_file(self, file_record: FileRecord) -> None:
8472
"""update file record"""
85-
pass
8673

8774
@abstractmethod
8875
async def update_batch(self, batch_record: BatchRecord) -> BatchRecord:
89-
pass
76+
"""Update a batch record"""
9077

9178
@abstractmethod
9279
async def delete_all(self, user_id: str) -> None:
9380
"""Delete all batches, files, and logs for a user"""
94-
pass
9581

9682
@abstractmethod
9783
async def delete_batch(self, user_id: str, batch_id: str) -> None:
9884
"""Delete a batch along with its files and logs"""
99-
pass
10085

10186
@abstractmethod
10287
async def delete_file(self, user_id: str, batch_id: str, file_id: str) -> None:
10388
"""Delete a file and its logs, and update batch file count"""
104-
pass
10589

10690
@abstractmethod
10791
async def get_batch_history(self, user_id: str, batch_id: str) -> List[Dict]:
10892
"""Retrieve all logs for a batch"""
109-
pass
11093

11194
@abstractmethod
11295
async def close(self) -> None:
11396
"""Close database connection"""
114-
pass

0 commit comments

Comments
 (0)