|
@@ -36,6 +36,9 @@ from script_build_host.domain.workspaces import (
|
|
|
)
|
|
)
|
|
|
from script_build_host.infrastructure.canonical_json import canonical_sha256, normalize_json
|
|
from script_build_host.infrastructure.canonical_json import canonical_sha256, normalize_json
|
|
|
from script_build_host.infrastructure.legacy_tables import (
|
|
from script_build_host.infrastructure.legacy_tables import (
|
|
|
|
|
+ script_build_candidate_element,
|
|
|
|
|
+ script_build_candidate_paragraph,
|
|
|
|
|
+ script_build_candidate_paragraph_element,
|
|
|
script_build_element,
|
|
script_build_element,
|
|
|
script_build_paragraph,
|
|
script_build_paragraph,
|
|
|
script_build_paragraph_element,
|
|
script_build_paragraph_element,
|
|
@@ -71,6 +74,15 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
) -> None:
|
|
) -> None:
|
|
|
self._sessions = sessions
|
|
self._sessions = sessions
|
|
|
self._artifacts = artifacts
|
|
self._artifacts = artifacts
|
|
|
|
|
+ bind = sessions.kw.get("bind")
|
|
|
|
|
+ use_views = getattr(getattr(bind, "dialect", None), "name", None) == "mysql"
|
|
|
|
|
+ self._paragraphs = script_build_candidate_paragraph if use_views else script_build_paragraph
|
|
|
|
|
+ self._elements = script_build_candidate_element if use_views else script_build_element
|
|
|
|
|
+ self._links = (
|
|
|
|
|
+ script_build_candidate_paragraph_element
|
|
|
|
|
+ if use_views
|
|
|
|
|
+ else script_build_paragraph_element
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
async def get_or_create(
|
|
async def get_or_create(
|
|
|
self,
|
|
self,
|
|
@@ -214,7 +226,7 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
"LEGACY_REFERENCE_INVALID", "child content range exceeds its parent"
|
|
"LEGACY_REFERENCE_INVALID", "child content range exceeds its parent"
|
|
|
)
|
|
)
|
|
|
result = await session.execute(
|
|
result = await session.execute(
|
|
|
- insert(script_build_paragraph).values(
|
|
|
|
|
|
|
+ insert(self._paragraphs).values(
|
|
|
script_build_id=workspace.script_build_id,
|
|
script_build_id=workspace.script_build_id,
|
|
|
branch_id=workspace.branch_id,
|
|
branch_id=workspace.branch_id,
|
|
|
base_ref_id=None,
|
|
base_ref_id=None,
|
|
@@ -356,11 +368,11 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
)
|
|
)
|
|
|
if values.get("is_active") is False:
|
|
if values.get("is_active") is False:
|
|
|
active_child = await session.scalar(
|
|
active_child = await session.scalar(
|
|
|
- select(script_build_paragraph.c.id).where(
|
|
|
|
|
- script_build_paragraph.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph.c.branch_id == workspace.branch_id,
|
|
|
|
|
- script_build_paragraph.c.parent_id == paragraph_id,
|
|
|
|
|
- script_build_paragraph.c.is_active.is_(True),
|
|
|
|
|
|
|
+ select(self._paragraphs.c.id).where(
|
|
|
|
|
+ self._paragraphs.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._paragraphs.c.branch_id == workspace.branch_id,
|
|
|
|
|
+ self._paragraphs.c.parent_id == paragraph_id,
|
|
|
|
|
+ self._paragraphs.c.is_active.is_(True),
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
if active_child is not None:
|
|
if active_child is not None:
|
|
@@ -374,21 +386,20 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
prepared.append((paragraph_id, values))
|
|
prepared.append((paragraph_id, values))
|
|
|
for paragraph_id, values in prepared:
|
|
for paragraph_id, values in prepared:
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- update(script_build_paragraph)
|
|
|
|
|
|
|
+ update(self._paragraphs)
|
|
|
.where(
|
|
.where(
|
|
|
- script_build_paragraph.c.id == paragraph_id,
|
|
|
|
|
- script_build_paragraph.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ self._paragraphs.c.id == paragraph_id,
|
|
|
|
|
+ self._paragraphs.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._paragraphs.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
.values(**values)
|
|
.values(**values)
|
|
|
)
|
|
)
|
|
|
if values.get("is_active") is False:
|
|
if values.get("is_active") is False:
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- delete(script_build_paragraph_element).where(
|
|
|
|
|
- script_build_paragraph_element.c.script_build_id
|
|
|
|
|
- == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
- script_build_paragraph_element.c.paragraph_id == paragraph_id,
|
|
|
|
|
|
|
+ delete(self._links).where(
|
|
|
|
|
+ self._links.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._links.c.branch_id == workspace.branch_id,
|
|
|
|
|
+ self._links.c.paragraph_id == paragraph_id,
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
return tuple(item[0] for item in prepared)
|
|
return tuple(item[0] for item in prepared)
|
|
@@ -419,8 +430,8 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
dimensions = {str(item.get("维度", "")) for item in existing}
|
|
dimensions = {str(item.get("维度", "")) for item in existing}
|
|
|
added = [item for item in normalized if item["维度"] not in dimensions]
|
|
added = [item for item in normalized if item["维度"] not in dimensions]
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- update(script_build_paragraph)
|
|
|
|
|
- .where(script_build_paragraph.c.id == paragraph_id)
|
|
|
|
|
|
|
+ update(self._paragraphs)
|
|
|
|
|
+ .where(self._paragraphs.c.id == paragraph_id)
|
|
|
.values(**{column: [*existing, *added], "updated_at": _now()})
|
|
.values(**{column: [*existing, *added], "updated_at": _now()})
|
|
|
)
|
|
)
|
|
|
return len(added)
|
|
return len(added)
|
|
@@ -460,8 +471,8 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
if deleted_count == 0:
|
|
if deleted_count == 0:
|
|
|
raise WorkspaceError("LEGACY_REFERENCE_INVALID", "paragraph atom does not exist")
|
|
raise WorkspaceError("LEGACY_REFERENCE_INVALID", "paragraph atom does not exist")
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- update(script_build_paragraph)
|
|
|
|
|
- .where(script_build_paragraph.c.id == paragraph_id)
|
|
|
|
|
|
|
+ update(self._paragraphs)
|
|
|
|
|
+ .where(self._paragraphs.c.id == paragraph_id)
|
|
|
.values(**{column: kept, "updated_at": _now()})
|
|
.values(**{column: kept, "updated_at": _now()})
|
|
|
)
|
|
)
|
|
|
return deleted_count
|
|
return deleted_count
|
|
@@ -487,13 +498,12 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
existing = (
|
|
existing = (
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_element.c.id).where(
|
|
|
|
|
- script_build_element.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
- script_build_element.c.name == name.strip(),
|
|
|
|
|
- script_build_element.c.dimension_primary == dimension_primary,
|
|
|
|
|
- script_build_element.c.dimension_secondary
|
|
|
|
|
- == dimension_secondary.strip(),
|
|
|
|
|
|
|
+ select(self._elements.c.id).where(
|
|
|
|
|
+ self._elements.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._elements.c.branch_id == workspace.branch_id,
|
|
|
|
|
+ self._elements.c.name == name.strip(),
|
|
|
|
|
+ self._elements.c.dimension_primary == dimension_primary,
|
|
|
|
|
+ self._elements.c.dimension_secondary == dimension_secondary.strip(),
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
@@ -503,7 +513,7 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
if existing is not None:
|
|
if existing is not None:
|
|
|
return int(existing)
|
|
return int(existing)
|
|
|
result = await session.execute(
|
|
result = await session.execute(
|
|
|
- insert(script_build_element).values(
|
|
|
|
|
|
|
+ insert(self._elements).values(
|
|
|
script_build_id=workspace.script_build_id,
|
|
script_build_id=workspace.script_build_id,
|
|
|
branch_id=workspace.branch_id,
|
|
branch_id=workspace.branch_id,
|
|
|
base_ref_id=None,
|
|
base_ref_id=None,
|
|
@@ -582,21 +592,20 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
raise WorkspaceError("LEGACY_WRITE_INVALID", "element is_active must be boolean")
|
|
raise WorkspaceError("LEGACY_WRITE_INVALID", "element is_active must be boolean")
|
|
|
normalized["updated_at"] = _now()
|
|
normalized["updated_at"] = _now()
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- update(script_build_element)
|
|
|
|
|
|
|
+ update(self._elements)
|
|
|
.where(
|
|
.where(
|
|
|
- script_build_element.c.id == element_id,
|
|
|
|
|
- script_build_element.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ self._elements.c.id == element_id,
|
|
|
|
|
+ self._elements.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._elements.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
.values(**normalized)
|
|
.values(**normalized)
|
|
|
)
|
|
)
|
|
|
if normalized.get("is_active") is False:
|
|
if normalized.get("is_active") is False:
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- delete(script_build_paragraph_element).where(
|
|
|
|
|
- script_build_paragraph_element.c.script_build_id
|
|
|
|
|
- == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
- script_build_paragraph_element.c.element_id == element_id,
|
|
|
|
|
|
|
+ delete(self._links).where(
|
|
|
|
|
+ self._links.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._links.c.branch_id == workspace.branch_id,
|
|
|
|
|
+ self._links.c.element_id == element_id,
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -630,12 +639,11 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
exists = (
|
|
exists = (
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_paragraph_element.c.id).where(
|
|
|
|
|
- script_build_paragraph_element.c.script_build_id
|
|
|
|
|
- == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
- script_build_paragraph_element.c.paragraph_id == paragraph_id,
|
|
|
|
|
- script_build_paragraph_element.c.element_id == element_id,
|
|
|
|
|
|
|
+ select(self._links.c.id).where(
|
|
|
|
|
+ self._links.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._links.c.branch_id == workspace.branch_id,
|
|
|
|
|
+ self._links.c.paragraph_id == paragraph_id,
|
|
|
|
|
+ self._links.c.element_id == element_id,
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
@@ -644,7 +652,7 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
)
|
|
)
|
|
|
if exists is None:
|
|
if exists is None:
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- insert(script_build_paragraph_element).values(
|
|
|
|
|
|
|
+ insert(self._links).values(
|
|
|
script_build_id=workspace.script_build_id,
|
|
script_build_id=workspace.script_build_id,
|
|
|
branch_id=workspace.branch_id,
|
|
branch_id=workspace.branch_id,
|
|
|
paragraph_id=paragraph_id,
|
|
paragraph_id=paragraph_id,
|
|
@@ -681,10 +689,9 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
rows = (
|
|
rows = (
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_paragraph_element).where(
|
|
|
|
|
- script_build_paragraph_element.c.script_build_id
|
|
|
|
|
- == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ select(self._links).where(
|
|
|
|
|
+ self._links.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._links.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
@@ -699,11 +706,10 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
for item in (
|
|
for item in (
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_paragraph.c.id).where(
|
|
|
|
|
- script_build_paragraph.c.script_build_id
|
|
|
|
|
- == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph.c.branch_id == workspace.branch_id,
|
|
|
|
|
- script_build_paragraph.c.is_active.is_(True),
|
|
|
|
|
|
|
+ select(self._paragraphs.c.id).where(
|
|
|
|
|
+ self._paragraphs.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._paragraphs.c.branch_id == workspace.branch_id,
|
|
|
|
|
+ self._paragraphs.c.is_active.is_(True),
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
@@ -714,10 +720,10 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
active_elements = set(
|
|
active_elements = set(
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_element.c.id).where(
|
|
|
|
|
- script_build_element.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
- script_build_element.c.is_active.is_(True),
|
|
|
|
|
|
|
+ select(self._elements.c.id).where(
|
|
|
|
|
+ self._elements.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._elements.c.branch_id == workspace.branch_id,
|
|
|
|
|
+ self._elements.c.is_active.is_(True),
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
).scalars()
|
|
).scalars()
|
|
@@ -737,11 +743,7 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
)
|
|
)
|
|
|
]
|
|
]
|
|
|
if delete_ids:
|
|
if delete_ids:
|
|
|
- await session.execute(
|
|
|
|
|
- delete(script_build_paragraph_element).where(
|
|
|
|
|
- script_build_paragraph_element.c.id.in_(delete_ids)
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ await session.execute(delete(self._links).where(self._links.c.id.in_(delete_ids)))
|
|
|
return len(delete_ids)
|
|
return len(delete_ids)
|
|
|
|
|
|
|
|
async def freeze(
|
|
async def freeze(
|
|
@@ -984,41 +986,41 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
)
|
|
)
|
|
|
return workspace
|
|
return workspace
|
|
|
|
|
|
|
|
- @staticmethod
|
|
|
|
|
async def _paragraph(
|
|
async def _paragraph(
|
|
|
|
|
+ self,
|
|
|
session: AsyncSession,
|
|
session: AsyncSession,
|
|
|
workspace: CandidateWorkspace,
|
|
workspace: CandidateWorkspace,
|
|
|
paragraph_id: int,
|
|
paragraph_id: int,
|
|
|
*,
|
|
*,
|
|
|
active: bool | None = None,
|
|
active: bool | None = None,
|
|
|
) -> Mapping[str, Any] | None:
|
|
) -> Mapping[str, Any] | None:
|
|
|
- statement = select(script_build_paragraph).where(
|
|
|
|
|
- script_build_paragraph.c.id == paragraph_id,
|
|
|
|
|
- script_build_paragraph.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ statement = select(self._paragraphs).where(
|
|
|
|
|
+ self._paragraphs.c.id == paragraph_id,
|
|
|
|
|
+ self._paragraphs.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._paragraphs.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
if active is not None:
|
|
if active is not None:
|
|
|
- statement = statement.where(script_build_paragraph.c.is_active.is_(active))
|
|
|
|
|
|
|
+ statement = statement.where(self._paragraphs.c.is_active.is_(active))
|
|
|
return cast(
|
|
return cast(
|
|
|
Mapping[str, Any] | None,
|
|
Mapping[str, Any] | None,
|
|
|
(await session.execute(statement)).mappings().one_or_none(),
|
|
(await session.execute(statement)).mappings().one_or_none(),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- @staticmethod
|
|
|
|
|
async def _element(
|
|
async def _element(
|
|
|
|
|
+ self,
|
|
|
session: AsyncSession,
|
|
session: AsyncSession,
|
|
|
workspace: CandidateWorkspace,
|
|
workspace: CandidateWorkspace,
|
|
|
element_id: int,
|
|
element_id: int,
|
|
|
*,
|
|
*,
|
|
|
active: bool | None = None,
|
|
active: bool | None = None,
|
|
|
) -> Mapping[str, Any] | None:
|
|
) -> Mapping[str, Any] | None:
|
|
|
- statement = select(script_build_element).where(
|
|
|
|
|
- script_build_element.c.id == element_id,
|
|
|
|
|
- script_build_element.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ statement = select(self._elements).where(
|
|
|
|
|
+ self._elements.c.id == element_id,
|
|
|
|
|
+ self._elements.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._elements.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
if active is not None:
|
|
if active is not None:
|
|
|
- statement = statement.where(script_build_element.c.is_active.is_(active))
|
|
|
|
|
|
|
+ statement = statement.where(self._elements.c.is_active.is_(active))
|
|
|
return cast(
|
|
return cast(
|
|
|
Mapping[str, Any] | None,
|
|
Mapping[str, Any] | None,
|
|
|
(await session.execute(statement)).mappings().one_or_none(),
|
|
(await session.execute(statement)).mappings().one_or_none(),
|
|
@@ -1030,14 +1032,14 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
paragraph_rows = (
|
|
paragraph_rows = (
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_paragraph)
|
|
|
|
|
|
|
+ select(self._paragraphs)
|
|
|
.where(
|
|
.where(
|
|
|
- script_build_paragraph.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ self._paragraphs.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._paragraphs.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
.order_by(
|
|
.order_by(
|
|
|
- script_build_paragraph.c.paragraph_index,
|
|
|
|
|
- script_build_paragraph.c.id,
|
|
|
|
|
|
|
+ self._paragraphs.c.paragraph_index,
|
|
|
|
|
+ self._paragraphs.c.id,
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
@@ -1047,12 +1049,12 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
element_rows = (
|
|
element_rows = (
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_element)
|
|
|
|
|
|
|
+ select(self._elements)
|
|
|
.where(
|
|
.where(
|
|
|
- script_build_element.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
- script_build_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ self._elements.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._elements.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
- .order_by(script_build_element.c.id)
|
|
|
|
|
|
|
+ .order_by(self._elements.c.id)
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
.mappings()
|
|
.mappings()
|
|
@@ -1061,15 +1063,14 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
link_rows = (
|
|
link_rows = (
|
|
|
(
|
|
(
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- select(script_build_paragraph_element)
|
|
|
|
|
|
|
+ select(self._links)
|
|
|
.where(
|
|
.where(
|
|
|
- script_build_paragraph_element.c.script_build_id
|
|
|
|
|
- == workspace.script_build_id,
|
|
|
|
|
- script_build_paragraph_element.c.branch_id == workspace.branch_id,
|
|
|
|
|
|
|
+ self._links.c.script_build_id == workspace.script_build_id,
|
|
|
|
|
+ self._links.c.branch_id == workspace.branch_id,
|
|
|
)
|
|
)
|
|
|
.order_by(
|
|
.order_by(
|
|
|
- script_build_paragraph_element.c.paragraph_id,
|
|
|
|
|
- script_build_paragraph_element.c.element_id,
|
|
|
|
|
|
|
+ self._links.c.paragraph_id,
|
|
|
|
|
+ self._links.c.element_id,
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
@@ -1164,7 +1165,7 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
for item in sorted(paragraphs, key=lambda value: (value.level, value.paragraph_index)):
|
|
for item in sorted(paragraphs, key=lambda value: (value.level, value.paragraph_index)):
|
|
|
parent_id = paragraph_map.get(item.parent_id) if item.parent_id is not None else None
|
|
parent_id = paragraph_map.get(item.parent_id) if item.parent_id is not None else None
|
|
|
result = await session.execute(
|
|
result = await session.execute(
|
|
|
- insert(script_build_paragraph).values(
|
|
|
|
|
|
|
+ insert(self._paragraphs).values(
|
|
|
script_build_id=workspace.script_build_id,
|
|
script_build_id=workspace.script_build_id,
|
|
|
branch_id=workspace.branch_id,
|
|
branch_id=workspace.branch_id,
|
|
|
base_ref_id=item.paragraph_id,
|
|
base_ref_id=item.paragraph_id,
|
|
@@ -1192,7 +1193,7 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
element_map: dict[int, int] = {}
|
|
element_map: dict[int, int] = {}
|
|
|
for item in elements:
|
|
for item in elements:
|
|
|
result = await session.execute(
|
|
result = await session.execute(
|
|
|
- insert(script_build_element).values(
|
|
|
|
|
|
|
+ insert(self._elements).values(
|
|
|
script_build_id=workspace.script_build_id,
|
|
script_build_id=workspace.script_build_id,
|
|
|
branch_id=workspace.branch_id,
|
|
branch_id=workspace.branch_id,
|
|
|
base_ref_id=item.element_id,
|
|
base_ref_id=item.element_id,
|
|
@@ -1214,7 +1215,7 @@ class SqlAlchemyCandidateWorkspaceRepository:
|
|
|
element_id = element_map.get(item.element_id)
|
|
element_id = element_map.get(item.element_id)
|
|
|
if paragraph_id is not None and element_id is not None:
|
|
if paragraph_id is not None and element_id is not None:
|
|
|
await session.execute(
|
|
await session.execute(
|
|
|
- insert(script_build_paragraph_element).values(
|
|
|
|
|
|
|
+ insert(self._links).values(
|
|
|
script_build_id=workspace.script_build_id,
|
|
script_build_id=workspace.script_build_id,
|
|
|
branch_id=workspace.branch_id,
|
|
branch_id=workspace.branch_id,
|
|
|
paragraph_id=paragraph_id,
|
|
paragraph_id=paragraph_id,
|