Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 2d9f292

Browse files
committed
Set the 'primary_table' when creating a new source record
1 parent e7bc24c commit 2d9f292

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

api/routes/sources.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
import urllib.parse
23
from typing import List, Literal, Union
34

@@ -115,7 +116,8 @@ async def post_source(source: Sources.Post, user_has_access: bool = Depends(has_
115116
async_session = get_async_session(engine)
116117

117118
if source.slug is None:
118-
source.slug = slugify(source.name, max_length=10).replace("-", "_")
119+
source.slug = re.sub(r"\W", "_", slugify(source.name, max_length=10))
120+
source.primary_table = source.slug + "_polygons"
119121

120122
async with async_session() as session:
121123
insert_stmt = insert(schemas.Sources).values(**source.model_dump()).returning(schemas.Sources)

0 commit comments

Comments
 (0)