Skip to content

Commit

Permalink
Fix sync schema method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcjc712 committed Apr 23, 2024
1 parent e3800f8 commit 5e76e53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions dataherald/api/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def scan_db(

db_connection_repository = DatabaseConnectionRepository(self.storage)
scanner = self.system.instance(Scanner)
rows = scanner.synchronizing(
scanner_request,
TableDescriptionRepository(self.storage),
)
database_connection_service = DatabaseConnectionService(scanner, self.storage)
for schema, table_descriptions in data.items():
db_connection = db_connection_repository.find_by_id(
Expand All @@ -156,11 +160,7 @@ def scan_db(
background_tasks.add_task(
async_scanning, scanner, database, table_descriptions, self.storage
)
return [
TableDescriptionResponse(**row.dict())
for _, table_descriptions in data.items()
for row in table_descriptions
]
return [TableDescriptionResponse(**row.dict()) for row in rows]

@override
def create_database_connection(
Expand Down
8 changes: 4 additions & 4 deletions dataherald/db_scanner/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ def synchronizing(
scanner_request: ScannerRequest,
repository: TableDescriptionRepository,
) -> list[TableDescription]:
# persist tables to be scanned
rows = []
for table in scanner_request.table_names:
for id in scanner_request.ids:
table_description = repository.find_by_id(id)
rows.append(
repository.save_table_info(
TableDescription(
db_connection_id=scanner_request.db_connection_id,
table_name=table,
db_connection_id=table_description.db_connection_id,
table_name=table_description.table_name,
status=TableDescriptionStatus.SYNCHRONIZING.value,
metadata=scanner_request.metadata,
)
Expand Down

0 comments on commit 5e76e53

Please sign in to comment.