diff --git a/.sqlx/query-4f8bb1345f524f5a11ae74357265d8e308eebb562117bb3f36c3b25f9e1c5e1b.json b/.sqlx/query-6aca3fde126cb1761c0a5ce1fbfa793bdbac4aed137cdf60eb3f277f36d7bf7a.json similarity index 85% rename from .sqlx/query-4f8bb1345f524f5a11ae74357265d8e308eebb562117bb3f36c3b25f9e1c5e1b.json rename to .sqlx/query-6aca3fde126cb1761c0a5ce1fbfa793bdbac4aed137cdf60eb3f277f36d7bf7a.json index 26ca040f..1d2809b7 100644 --- a/.sqlx/query-4f8bb1345f524f5a11ae74357265d8e308eebb562117bb3f36c3b25f9e1c5e1b.json +++ b/.sqlx/query-6aca3fde126cb1761c0a5ce1fbfa793bdbac4aed137cdf60eb3f277f36d7bf7a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n category_id AS id,\n name,\n description,\n icon,\n bg_color,\n category_type AS \"category_type: AFTemplateCategoryTypeColumn\",\n rank\n FROM af_template_category\n WHERE category_id = $1\n ", + "query": "\n SELECT\n category_id AS id,\n name,\n description,\n icon,\n bg_color,\n category_type AS \"category_type: AFTemplateCategoryTypeColumn\",\n priority\n FROM af_template_category\n WHERE category_id = $1\n ", "describe": { "columns": [ { @@ -35,7 +35,7 @@ }, { "ordinal": 6, - "name": "rank", + "name": "priority", "type_info": "Int4" } ], @@ -54,5 +54,5 @@ false ] }, - "hash": "4f8bb1345f524f5a11ae74357265d8e308eebb562117bb3f36c3b25f9e1c5e1b" + "hash": "6aca3fde126cb1761c0a5ce1fbfa793bdbac4aed137cdf60eb3f277f36d7bf7a" } diff --git a/.sqlx/query-e011a91040db0ffdaf46c859e58b14ad6503b2f4eab33d3b32d677c9731aae79.json b/.sqlx/query-ae6558fb998c524e9a1fa4f0e0b36d95b38310ff841036b5d8d9b7ae98cd70fb.json similarity index 74% rename from .sqlx/query-e011a91040db0ffdaf46c859e58b14ad6503b2f4eab33d3b32d677c9731aae79.json rename to .sqlx/query-ae6558fb998c524e9a1fa4f0e0b36d95b38310ff841036b5d8d9b7ae98cd70fb.json index b50b68b2..e5fff37e 100644 --- a/.sqlx/query-e011a91040db0ffdaf46c859e58b14ad6503b2f4eab33d3b32d677c9731aae79.json +++ b/.sqlx/query-ae6558fb998c524e9a1fa4f0e0b36d95b38310ff841036b5d8d9b7ae98cd70fb.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n UPDATE af_template_category\n SET\n name = $2,\n description = $3,\n icon = $4,\n bg_color = $5,\n category_type = $6,\n rank = $7\n WHERE category_id = $1\n RETURNING\n category_id AS id,\n name,\n description,\n icon,\n bg_color,\n category_type AS \"category_type: AFTemplateCategoryTypeColumn\",\n rank\n ", + "query": "\n UPDATE af_template_category\n SET\n name = $2,\n description = $3,\n icon = $4,\n bg_color = $5,\n category_type = $6,\n priority = $7\n WHERE category_id = $1\n RETURNING\n category_id AS id,\n name,\n description,\n icon,\n bg_color,\n category_type AS \"category_type: AFTemplateCategoryTypeColumn\",\n priority\n ", "describe": { "columns": [ { @@ -35,7 +35,7 @@ }, { "ordinal": 6, - "name": "rank", + "name": "priority", "type_info": "Int4" } ], @@ -60,5 +60,5 @@ false ] }, - "hash": "e011a91040db0ffdaf46c859e58b14ad6503b2f4eab33d3b32d677c9731aae79" + "hash": "ae6558fb998c524e9a1fa4f0e0b36d95b38310ff841036b5d8d9b7ae98cd70fb" } diff --git a/.sqlx/query-b9d4e564e23df7ab391c78848b6a9d51e30496c58e70b26f14dfe55b6a0d2e69.json b/.sqlx/query-cb2375ad0094baefed417645b781f40dcabfbfe4a4738c99bb4efff649e6a0e6.json similarity index 73% rename from .sqlx/query-b9d4e564e23df7ab391c78848b6a9d51e30496c58e70b26f14dfe55b6a0d2e69.json rename to .sqlx/query-cb2375ad0094baefed417645b781f40dcabfbfe4a4738c99bb4efff649e6a0e6.json index 927ffcaf..e8f46cf4 100644 --- a/.sqlx/query-b9d4e564e23df7ab391c78848b6a9d51e30496c58e70b26f14dfe55b6a0d2e69.json +++ b/.sqlx/query-cb2375ad0094baefed417645b781f40dcabfbfe4a4738c99bb4efff649e6a0e6.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n INSERT INTO af_template_category (name, description, icon, bg_color, category_type, rank)\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING\n category_id AS id,\n name,\n description,\n icon,\n bg_color,\n category_type AS \"category_type: AFTemplateCategoryTypeColumn\",\n rank\n ", + "query": "\n INSERT INTO af_template_category (name, description, icon, bg_color, category_type, priority)\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING\n category_id AS id,\n name,\n description,\n icon,\n bg_color,\n category_type AS \"category_type: AFTemplateCategoryTypeColumn\",\n priority\n ", "describe": { "columns": [ { @@ -35,7 +35,7 @@ }, { "ordinal": 6, - "name": "rank", + "name": "priority", "type_info": "Int4" } ], @@ -59,5 +59,5 @@ false ] }, - "hash": "b9d4e564e23df7ab391c78848b6a9d51e30496c58e70b26f14dfe55b6a0d2e69" + "hash": "cb2375ad0094baefed417645b781f40dcabfbfe4a4738c99bb4efff649e6a0e6" } diff --git a/libs/client-api/src/http_template.rs b/libs/client-api/src/http_template.rs index 05ae6b5e..87fe0b03 100644 --- a/libs/client-api/src/http_template.rs +++ b/libs/client-api/src/http_template.rs @@ -42,7 +42,7 @@ impl Client { bg_color: &str, description: &str, category_type: TemplateCategoryType, - rank: i32, + priority: i32, ) -> Result { let url = category_resources_url(&self.base_url); let resp = self @@ -53,7 +53,7 @@ impl Client { icon: icon.to_string(), bg_color: bg_color.to_string(), description: description.to_string(), - rank, + priority, category_type, }) .send() @@ -118,7 +118,7 @@ impl Client { bg_color: &str, description: &str, category_type: TemplateCategoryType, - rank: i32, + priority: i32, ) -> Result { let url = category_resource_url(&self.base_url, category_id); let resp = self @@ -130,7 +130,7 @@ impl Client { bg_color: bg_color.to_string(), description: description.to_string(), category_type, - rank, + priority, }) .send() .await?; diff --git a/libs/database-entity/src/dto.rs b/libs/database-entity/src/dto.rs index 94da0ae9..93380e47 100644 --- a/libs/database-entity/src/dto.rs +++ b/libs/database-entity/src/dto.rs @@ -1017,7 +1017,7 @@ pub struct TemplateCategory { pub bg_color: String, pub description: String, pub category_type: TemplateCategoryType, - pub rank: i32, + pub priority: i32, } #[derive(Serialize, Deserialize, Debug)] @@ -1027,7 +1027,7 @@ pub struct CreateTemplateCategoryParams { pub bg_color: String, pub description: String, pub category_type: TemplateCategoryType, - pub rank: i32, + pub priority: i32, } #[derive(Serialize, Deserialize, Debug)] @@ -1043,7 +1043,7 @@ pub struct UpdateTemplateCategoryParams { pub bg_color: String, pub description: String, pub category_type: TemplateCategoryType, - pub rank: i32, + pub priority: i32, } #[derive(Serialize, Deserialize, Debug)] diff --git a/libs/database/src/pg_row.rs b/libs/database/src/pg_row.rs index 8b4ecb53..c6135e38 100644 --- a/libs/database/src/pg_row.rs +++ b/libs/database/src/pg_row.rs @@ -284,7 +284,7 @@ pub struct AFTemplateCategoryRow { pub bg_color: String, pub description: String, pub category_type: AFTemplateCategoryTypeColumn, - pub rank: i32, + pub priority: i32, } impl From for TemplateCategory { @@ -296,7 +296,7 @@ impl From for TemplateCategory { bg_color: value.bg_color, description: value.description, category_type: value.category_type.into(), - rank: value.rank, + priority: value.priority, } } } diff --git a/libs/database/src/template.rs b/libs/database/src/template.rs index 58762875..fb0c41e9 100644 --- a/libs/database/src/template.rs +++ b/libs/database/src/template.rs @@ -14,13 +14,13 @@ pub async fn insert_new_template_category<'a, E: Executor<'a, Database = Postgre icon: &str, bg_color: &str, category_type: TemplateCategoryType, - rank: i32, + priority: i32, ) -> Result { let category_type_column: AFTemplateCategoryTypeColumn = category_type.into(); let new_template_category = sqlx::query_as!( TemplateCategory, r#" - INSERT INTO af_template_category (name, description, icon, bg_color, category_type, rank) + INSERT INTO af_template_category (name, description, icon, bg_color, category_type, priority) VALUES ($1, $2, $3, $4, $5, $6) RETURNING category_id AS id, @@ -29,14 +29,14 @@ pub async fn insert_new_template_category<'a, E: Executor<'a, Database = Postgre icon, bg_color, category_type AS "category_type: AFTemplateCategoryTypeColumn", - rank + priority "#, name, description, icon, bg_color, category_type_column as AFTemplateCategoryTypeColumn, - rank, + priority, ) .fetch_one(executor) .await?; @@ -52,7 +52,7 @@ pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postg icon: &str, bg_color: &str, category_type: TemplateCategoryType, - rank: i32, + priority: i32, ) -> Result { let category_type_column: AFTemplateCategoryTypeColumn = category_type.into(); let new_template_category = sqlx::query_as!( @@ -65,7 +65,7 @@ pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postg icon = $4, bg_color = $5, category_type = $6, - rank = $7 + priority = $7 WHERE category_id = $1 RETURNING category_id AS id, @@ -74,7 +74,7 @@ pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postg icon, bg_color, category_type AS "category_type: AFTemplateCategoryTypeColumn", - rank + priority "#, id, name, @@ -82,7 +82,7 @@ pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postg icon, bg_color, category_type_column as AFTemplateCategoryTypeColumn, - rank, + priority, ) .fetch_one(executor) .await?; @@ -103,7 +103,7 @@ pub async fn select_template_categories<'a, E: Executor<'a, Database = Postgres> icon, bg_color, category_type, - rank + priority FROM af_template_category WHERE TRUE "#, @@ -118,7 +118,7 @@ pub async fn select_template_categories<'a, E: Executor<'a, Database = Postgres> query_builder.push_bind(name_contains); query_builder.push(" , '%')"); }; - query_builder.push(" ORDER BY rank ASC"); + query_builder.push(" ORDER BY priority DESC"); let query = query_builder.build_query_as::(); let category_rows: Vec = query.fetch_all(executor).await?; @@ -141,7 +141,7 @@ pub async fn select_template_category_by_id<'a, E: Executor<'a, Database = Postg icon, bg_color, category_type AS "category_type: AFTemplateCategoryTypeColumn", - rank + priority FROM af_template_category WHERE category_id = $1 "#, diff --git a/migrations/20240806054557_template_category.sql b/migrations/20240806054557_template_category.sql index 55c51d9f..934b8851 100644 --- a/migrations/20240806054557_template_category.sql +++ b/migrations/20240806054557_template_category.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS af_template_category ( description TEXT NOT NULL, bg_color TEXT NOT NULL, category_type INT NOT NULL, - rank INT NOT NULL, + priority INT NOT NULL, PRIMARY KEY (category_id) ); diff --git a/migrations/20240806103039_template_creator.sql b/migrations/20240806103039_template_creator.sql index 31174141..071c6583 100644 --- a/migrations/20240806103039_template_creator.sql +++ b/migrations/20240806103039_template_creator.sql @@ -11,6 +11,5 @@ CREATE TABLE IF NOT EXISTS af_template_creator_account_link ( link_type TEXT NOT NULL, url TEXT NOT NULL, - UNIQUE(creator_id, link_type) + PRIMARY KEY (creator_id, link_type) ); -CREATE INDEX IF NOT EXISTS idx_creator_id_on_af_template_creator_account_link ON af_template_creator_account_link(creator_id); diff --git a/src/api/template.rs b/src/api/template.rs index 11071cf8..fc65fec9 100644 --- a/src/api/template.rs +++ b/src/api/template.rs @@ -56,7 +56,7 @@ async fn post_template_category_handler( &data.icon, &data.bg_color, data.category_type, - data.rank, + data.priority, ) .await?; Ok(Json(AppResponse::Ok().with_data(new_template_category))) @@ -91,7 +91,7 @@ async fn update_template_category_handler( &data.icon, &data.bg_color, data.category_type, - data.rank, + data.priority, ) .await?; Ok(Json(AppResponse::Ok().with_data(updated_template_category))) diff --git a/tests/workspace/template.rs b/tests/workspace/template.rs index 455dfc85..f7287a5e 100644 --- a/tests/workspace/template.rs +++ b/tests/workspace/template.rs @@ -74,7 +74,7 @@ async fn test_template_category_crud() { new_template_category.category_type, TemplateCategoryType::Feature ); - assert_eq!(new_template_category.rank, 1); + assert_eq!(new_template_category.priority, 1); let updated_category_name = Uuid::new_v4().to_string(); let updated_template_category = authorized_client .update_template_category( @@ -96,7 +96,7 @@ async fn test_template_category_crud() { updated_template_category.category_type, TemplateCategoryType::UseCase ); - assert_eq!(updated_template_category.rank, 2); + assert_eq!(updated_template_category.priority, 2); let guest_client = localhost_client(); let template_category = guest_client @@ -111,7 +111,7 @@ async fn test_template_category_crud() { template_category.category_type, TemplateCategoryType::UseCase ); - assert_eq!(template_category.rank, 2); + assert_eq!(template_category.priority, 2); let second_category_name = Uuid::new_v4().to_string(); authorized_client