sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #08387
[Merge] ~thorsten-merten/maas-site-manager:1529-add-name-unique-property2 into maas-site-manager:main
Thorsten Merten has proposed merging ~thorsten-merten/maas-site-manager:1529-add-name-unique-property2 into maas-site-manager:main.
Commit message:
feat: add name_duplicate column
* add column
* remove uniqueness constraint on name
* update test data and import script
Requested reviews:
MAAS Committers (maas-committers)
For more details, see:
https://code.launchpad.net/~thorsten-merten/maas-site-manager/+git/maas-site-manager/+merge/442839
--
Your team MAAS Committers is requested to review the proposed merge of ~thorsten-merten/maas-site-manager:1529-add-name-unique-property2 into maas-site-manager:main.
diff --git a/backend/msm/db/_tables.py b/backend/msm/db/_tables.py
index 70affca..1fa9662 100644
--- a/backend/msm/db/_tables.py
+++ b/backend/msm/db/_tables.py
@@ -23,7 +23,8 @@ Site = Table(
Column("country", Text), # ISO 3166 Alpha2
Column("latitude", Text),
Column("longitude", Text),
- Column("name", Text, unique=True),
+ Column("name", Text),
+ Column("name_unique", Boolean),
Column("note", Text),
Column("region", Text),
Column("street", Text),
diff --git a/backend/msm/db/models.py b/backend/msm/db/models.py
index ec3d032..ff3806f 100644
--- a/backend/msm/db/models.py
+++ b/backend/msm/db/models.py
@@ -26,6 +26,7 @@ class Site(BaseModel):
id: int
name: str
+ name_unique: bool
city: str | None
country: str | None = Field(min_length=2, max_length=2)
latitude: str | None
diff --git a/backend/msm/db/queries.py b/backend/msm/db/queries.py
index 803aa81..bb2e1a3 100644
--- a/backend/msm/db/queries.py
+++ b/backend/msm/db/queries.py
@@ -150,6 +150,7 @@ async def get_sites(
select(
Site.c.id,
Site.c.name,
+ Site.c.name_unique,
Site.c.city,
Site.c.country,
Site.c.latitude,
diff --git a/backend/tests/user_api/test_handlers.py b/backend/tests/user_api/test_handlers.py
index 348747f..a74ab8f 100644
--- a/backend/tests/user_api/test_handlers.py
+++ b/backend/tests/user_api/test_handlers.py
@@ -28,6 +28,7 @@ def site_details(**extra_details: Any) -> dict[str, Any]:
"""Return sample details for creating a site."""
details = {
"name": "LondonHQ",
+ "name_unique": True,
"url": "https://londoncalling.example.com",
"accepted": True,
}
diff --git a/test-data/import.sh b/test-data/import.sh
index da238be..f0163b1 100755
--- a/test-data/import.sh
+++ b/test-data/import.sh
@@ -35,7 +35,7 @@ EOF
fi
(
- copy_cmd sites.csv 'site(id, city, country, latitude, longitude, name, note, region, street, timezone, url, accepted, created)'
+ copy_cmd sites.csv 'site(id, city, country, latitude, longitude, name, name_unique, note, region, street, timezone, url, accepted, created)'
copy_cmd tokens.csv 'token(site_id, value, expired, created)'
copy_cmd users.csv '"user"(email, full_name, password)'
copy_cmd site_data.csv 'site_data(site_id, allocated_machines, deployed_machines, ready_machines, error_machines, last_seen)'
diff --git a/test-data/sites.csv b/test-data/sites.csv
index b25a675..f83ba96 100644
--- a/test-data/sites.csv
+++ b/test-data/sites.csv
@@ -1,9 +1,10 @@
-id,city,country,latitude,longitude,name,note,region,street,timezone,url,accepted,created
-1,London,GB,51.501990,-0.092200,Canonical Group Limited,4th Floor,,201 Borough High Street,Europe/London,https://london.canonical.example.com,t,2023-04-19 14:01:40.107611
-2,Austin,US,30.269612,-97.741057,Canonical USA Inc.,Perry Brooks Building - Suite 300,,720 Brazos Street,America/Chicago,https://austin.canonical.example.com,t,2023-04-28 14:01:34.229025
-3,Boston,US,42.358859,-71.059615,Canonical USA Inc. 001,Suite 210,,18 Tremont Street,America/Chicago,https://boston.canonical.example.com,t,2023-05-04 14:01:49.706886
-4,Shanghai,CN,31.187270,121.436829,Canonical China,上海市漕溪北路331号12楼1246室,,No. 331 North Caoxi Road,Asia/Shanghai,https://shanghai.canonical.example.com,f,2023-04-03 14:01:27.419476
-5,Beijing,CN,39.908447,116.448690,Canonical China 001,China World Office 1; 北京市朝阳区建国门外大街1号国贸写字楼1座11层1118-19室 100004,Chaoyang District,1 Jianguomenwai Avenue,Asia/Shanghai,https://shanghai.canonical.example.com,t,2023-05-03 15:02:11.107339
-6,Taipei City,TW,25.058098,121.543406,Canonical Group Limited - Taiwan Branch,105402 台北市松山區民生東路三段100號12樓,Songshan Dist.,"12F.,No. 100,Sec. 3,Minsheng E. Rd.",Asia/Taipei,https://taiwan.canonical.example.com,t,2023-05-04 14:02:24.156508
-7,Douglas,IM,54.153072,-4.481012,Canonical Limited,2nd Floor - Clarendon House,,Victoria Street,Europe/London,https://canonical.example.com,f,2023-04-13 14:02:31.611254
-8,Tokyo,JP,35.673242,139.740669,Canonical Japan K.K,3rd Floor - Sanno Park Tower,,2-11-1 Nagata-cho Chiyoda-ku,Japan,https://japan.canonical.example.com,t,2022-05-03 14:02:42.955134
+id,city,country,latitude,longitude,name,name_unique,note,region,street,timezone,url,accepted,created
+1,London,GB,51.501990,-0.092200,Canonical Group Limited,t,4th Floor,,201 Borough High Street,Europe/London,https://london.canonical.example.com,t,2023-04-19 14:01:40.107611
+2,Austin,US,30.269612,-97.741057,Canonical USA Inc.,t,Perry Brooks Building - Suite 300,,720 Brazos Street,America/Chicago,https://austin.canonical.example.com,t,2023-04-28 14:01:34.229025
+3,Boston,US,42.358859,-71.059615,Canonical USA Inc. 001,t,Suite 210,,18 Tremont Street,America/Chicago,https://boston.canonical.example.com,t,2023-05-04 14:01:49.706886
+4,Shanghai,CN,31.187270,121.436829,Canonical China,t,上海市漕溪北路331号12楼1246室,,No. 331 North Caoxi Road,Asia/Shanghai,https://shanghai.canonical.example.com,f,2023-04-03 14:01:27.419476
+5,Beijing,CN,39.908447,116.448690,Canonical China 001,t,China World Office 1; 北京市朝阳区建国门外大街1号国贸写字楼1座11层1118-19室 100004,Chaoyang District,1 Jianguomenwai Avenue,Asia/Shanghai,https://shanghai.canonical.example.com,t,2023-05-03 15:02:11.107339
+6,Taipei City,TW,25.058098,121.543406,Canonical Group Limited - Taiwan Branch,t,105402 台北市松山區民生東路三段100號12樓,Songshan Dist.,"12F.,No. 100,Sec. 3,Minsheng E. Rd.",Asia/Taipei,https://taiwan.canonical.example.com,t,2023-05-04 14:02:24.156508
+7,Douglas,IM,54.153072,-4.481012,Canonical Limited,t,2nd Floor - Clarendon House,,ictoria Street,Europe/London,https://canonical.example.com,f,2023-04-13 14:02:31.611254
+8,Tokyo,JP,35.673242,139.740669,Canonical Japan K.K,f,3rd Floor - Sanno Park Tower,,2-11-1 Nagata-cho Chiyoda-ku,Japan,https://japan.canonical.example.com,t,2022-05-03 14:02:42.955134
+9,Tokyo,JP,35.673242,139.740669,Canonical Japan K.K,f,Duplicate,,2-11-1 Nagata-cho Chiyoda-ku,Japan,https://japan.canonical.example.com,t,2022-05-03 14:02:42.955134
Follow ups