fix: replace rank with priority
This commit is contained in:
parent
fc56654e61
commit
59e5a13ee4
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"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": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "rank",
|
"name": "priority",
|
||||||
"type_info": "Int4"
|
"type_info": "Int4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -54,5 +54,5 @@
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "4f8bb1345f524f5a11ae74357265d8e308eebb562117bb3f36c3b25f9e1c5e1b"
|
"hash": "6aca3fde126cb1761c0a5ce1fbfa793bdbac4aed137cdf60eb3f277f36d7bf7a"
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"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": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "rank",
|
"name": "priority",
|
||||||
"type_info": "Int4"
|
"type_info": "Int4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -60,5 +60,5 @@
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "e011a91040db0ffdaf46c859e58b14ad6503b2f4eab33d3b32d677c9731aae79"
|
"hash": "ae6558fb998c524e9a1fa4f0e0b36d95b38310ff841036b5d8d9b7ae98cd70fb"
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"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": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "rank",
|
"name": "priority",
|
||||||
"type_info": "Int4"
|
"type_info": "Int4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -59,5 +59,5 @@
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "b9d4e564e23df7ab391c78848b6a9d51e30496c58e70b26f14dfe55b6a0d2e69"
|
"hash": "cb2375ad0094baefed417645b781f40dcabfbfe4a4738c99bb4efff649e6a0e6"
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ impl Client {
|
||||||
bg_color: &str,
|
bg_color: &str,
|
||||||
description: &str,
|
description: &str,
|
||||||
category_type: TemplateCategoryType,
|
category_type: TemplateCategoryType,
|
||||||
rank: i32,
|
priority: i32,
|
||||||
) -> Result<TemplateCategory, AppResponseError> {
|
) -> Result<TemplateCategory, AppResponseError> {
|
||||||
let url = category_resources_url(&self.base_url);
|
let url = category_resources_url(&self.base_url);
|
||||||
let resp = self
|
let resp = self
|
||||||
|
|
@ -53,7 +53,7 @@ impl Client {
|
||||||
icon: icon.to_string(),
|
icon: icon.to_string(),
|
||||||
bg_color: bg_color.to_string(),
|
bg_color: bg_color.to_string(),
|
||||||
description: description.to_string(),
|
description: description.to_string(),
|
||||||
rank,
|
priority,
|
||||||
category_type,
|
category_type,
|
||||||
})
|
})
|
||||||
.send()
|
.send()
|
||||||
|
|
@ -118,7 +118,7 @@ impl Client {
|
||||||
bg_color: &str,
|
bg_color: &str,
|
||||||
description: &str,
|
description: &str,
|
||||||
category_type: TemplateCategoryType,
|
category_type: TemplateCategoryType,
|
||||||
rank: i32,
|
priority: i32,
|
||||||
) -> Result<TemplateCategory, AppResponseError> {
|
) -> Result<TemplateCategory, AppResponseError> {
|
||||||
let url = category_resource_url(&self.base_url, category_id);
|
let url = category_resource_url(&self.base_url, category_id);
|
||||||
let resp = self
|
let resp = self
|
||||||
|
|
@ -130,7 +130,7 @@ impl Client {
|
||||||
bg_color: bg_color.to_string(),
|
bg_color: bg_color.to_string(),
|
||||||
description: description.to_string(),
|
description: description.to_string(),
|
||||||
category_type,
|
category_type,
|
||||||
rank,
|
priority,
|
||||||
})
|
})
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
|
|
@ -1017,7 +1017,7 @@ pub struct TemplateCategory {
|
||||||
pub bg_color: String,
|
pub bg_color: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub category_type: TemplateCategoryType,
|
pub category_type: TemplateCategoryType,
|
||||||
pub rank: i32,
|
pub priority: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
@ -1027,7 +1027,7 @@ pub struct CreateTemplateCategoryParams {
|
||||||
pub bg_color: String,
|
pub bg_color: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub category_type: TemplateCategoryType,
|
pub category_type: TemplateCategoryType,
|
||||||
pub rank: i32,
|
pub priority: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
@ -1043,7 +1043,7 @@ pub struct UpdateTemplateCategoryParams {
|
||||||
pub bg_color: String,
|
pub bg_color: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub category_type: TemplateCategoryType,
|
pub category_type: TemplateCategoryType,
|
||||||
pub rank: i32,
|
pub priority: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ pub struct AFTemplateCategoryRow {
|
||||||
pub bg_color: String,
|
pub bg_color: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub category_type: AFTemplateCategoryTypeColumn,
|
pub category_type: AFTemplateCategoryTypeColumn,
|
||||||
pub rank: i32,
|
pub priority: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AFTemplateCategoryRow> for TemplateCategory {
|
impl From<AFTemplateCategoryRow> for TemplateCategory {
|
||||||
|
|
@ -296,7 +296,7 @@ impl From<AFTemplateCategoryRow> for TemplateCategory {
|
||||||
bg_color: value.bg_color,
|
bg_color: value.bg_color,
|
||||||
description: value.description,
|
description: value.description,
|
||||||
category_type: value.category_type.into(),
|
category_type: value.category_type.into(),
|
||||||
rank: value.rank,
|
priority: value.priority,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,13 @@ pub async fn insert_new_template_category<'a, E: Executor<'a, Database = Postgre
|
||||||
icon: &str,
|
icon: &str,
|
||||||
bg_color: &str,
|
bg_color: &str,
|
||||||
category_type: TemplateCategoryType,
|
category_type: TemplateCategoryType,
|
||||||
rank: i32,
|
priority: i32,
|
||||||
) -> Result<TemplateCategory, AppError> {
|
) -> Result<TemplateCategory, AppError> {
|
||||||
let category_type_column: AFTemplateCategoryTypeColumn = category_type.into();
|
let category_type_column: AFTemplateCategoryTypeColumn = category_type.into();
|
||||||
let new_template_category = sqlx::query_as!(
|
let new_template_category = sqlx::query_as!(
|
||||||
TemplateCategory,
|
TemplateCategory,
|
||||||
r#"
|
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)
|
VALUES ($1, $2, $3, $4, $5, $6)
|
||||||
RETURNING
|
RETURNING
|
||||||
category_id AS id,
|
category_id AS id,
|
||||||
|
|
@ -29,14 +29,14 @@ pub async fn insert_new_template_category<'a, E: Executor<'a, Database = Postgre
|
||||||
icon,
|
icon,
|
||||||
bg_color,
|
bg_color,
|
||||||
category_type AS "category_type: AFTemplateCategoryTypeColumn",
|
category_type AS "category_type: AFTemplateCategoryTypeColumn",
|
||||||
rank
|
priority
|
||||||
"#,
|
"#,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
icon,
|
icon,
|
||||||
bg_color,
|
bg_color,
|
||||||
category_type_column as AFTemplateCategoryTypeColumn,
|
category_type_column as AFTemplateCategoryTypeColumn,
|
||||||
rank,
|
priority,
|
||||||
)
|
)
|
||||||
.fetch_one(executor)
|
.fetch_one(executor)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
@ -52,7 +52,7 @@ pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postg
|
||||||
icon: &str,
|
icon: &str,
|
||||||
bg_color: &str,
|
bg_color: &str,
|
||||||
category_type: TemplateCategoryType,
|
category_type: TemplateCategoryType,
|
||||||
rank: i32,
|
priority: i32,
|
||||||
) -> Result<TemplateCategory, AppError> {
|
) -> Result<TemplateCategory, AppError> {
|
||||||
let category_type_column: AFTemplateCategoryTypeColumn = category_type.into();
|
let category_type_column: AFTemplateCategoryTypeColumn = category_type.into();
|
||||||
let new_template_category = sqlx::query_as!(
|
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,
|
icon = $4,
|
||||||
bg_color = $5,
|
bg_color = $5,
|
||||||
category_type = $6,
|
category_type = $6,
|
||||||
rank = $7
|
priority = $7
|
||||||
WHERE category_id = $1
|
WHERE category_id = $1
|
||||||
RETURNING
|
RETURNING
|
||||||
category_id AS id,
|
category_id AS id,
|
||||||
|
|
@ -74,7 +74,7 @@ pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postg
|
||||||
icon,
|
icon,
|
||||||
bg_color,
|
bg_color,
|
||||||
category_type AS "category_type: AFTemplateCategoryTypeColumn",
|
category_type AS "category_type: AFTemplateCategoryTypeColumn",
|
||||||
rank
|
priority
|
||||||
"#,
|
"#,
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
|
|
@ -82,7 +82,7 @@ pub async fn update_template_category_by_id<'a, E: Executor<'a, Database = Postg
|
||||||
icon,
|
icon,
|
||||||
bg_color,
|
bg_color,
|
||||||
category_type_column as AFTemplateCategoryTypeColumn,
|
category_type_column as AFTemplateCategoryTypeColumn,
|
||||||
rank,
|
priority,
|
||||||
)
|
)
|
||||||
.fetch_one(executor)
|
.fetch_one(executor)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
@ -103,7 +103,7 @@ pub async fn select_template_categories<'a, E: Executor<'a, Database = Postgres>
|
||||||
icon,
|
icon,
|
||||||
bg_color,
|
bg_color,
|
||||||
category_type,
|
category_type,
|
||||||
rank
|
priority
|
||||||
FROM af_template_category
|
FROM af_template_category
|
||||||
WHERE TRUE
|
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_bind(name_contains);
|
||||||
query_builder.push(" , '%')");
|
query_builder.push(" , '%')");
|
||||||
};
|
};
|
||||||
query_builder.push(" ORDER BY rank ASC");
|
query_builder.push(" ORDER BY priority DESC");
|
||||||
let query = query_builder.build_query_as::<AFTemplateCategoryRow>();
|
let query = query_builder.build_query_as::<AFTemplateCategoryRow>();
|
||||||
|
|
||||||
let category_rows: Vec<AFTemplateCategoryRow> = query.fetch_all(executor).await?;
|
let category_rows: Vec<AFTemplateCategoryRow> = query.fetch_all(executor).await?;
|
||||||
|
|
@ -141,7 +141,7 @@ pub async fn select_template_category_by_id<'a, E: Executor<'a, Database = Postg
|
||||||
icon,
|
icon,
|
||||||
bg_color,
|
bg_color,
|
||||||
category_type AS "category_type: AFTemplateCategoryTypeColumn",
|
category_type AS "category_type: AFTemplateCategoryTypeColumn",
|
||||||
rank
|
priority
|
||||||
FROM af_template_category
|
FROM af_template_category
|
||||||
WHERE category_id = $1
|
WHERE category_id = $1
|
||||||
"#,
|
"#,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS af_template_category (
|
||||||
description TEXT NOT NULL,
|
description TEXT NOT NULL,
|
||||||
bg_color TEXT NOT NULL,
|
bg_color TEXT NOT NULL,
|
||||||
category_type INT NOT NULL,
|
category_type INT NOT NULL,
|
||||||
rank INT NOT NULL,
|
priority INT NOT NULL,
|
||||||
|
|
||||||
PRIMARY KEY (category_id)
|
PRIMARY KEY (category_id)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,5 @@ CREATE TABLE IF NOT EXISTS af_template_creator_account_link (
|
||||||
link_type TEXT NOT NULL,
|
link_type TEXT NOT NULL,
|
||||||
url 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);
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ async fn post_template_category_handler(
|
||||||
&data.icon,
|
&data.icon,
|
||||||
&data.bg_color,
|
&data.bg_color,
|
||||||
data.category_type,
|
data.category_type,
|
||||||
data.rank,
|
data.priority,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Json(AppResponse::Ok().with_data(new_template_category)))
|
Ok(Json(AppResponse::Ok().with_data(new_template_category)))
|
||||||
|
|
@ -91,7 +91,7 @@ async fn update_template_category_handler(
|
||||||
&data.icon,
|
&data.icon,
|
||||||
&data.bg_color,
|
&data.bg_color,
|
||||||
data.category_type,
|
data.category_type,
|
||||||
data.rank,
|
data.priority,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Json(AppResponse::Ok().with_data(updated_template_category)))
|
Ok(Json(AppResponse::Ok().with_data(updated_template_category)))
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ async fn test_template_category_crud() {
|
||||||
new_template_category.category_type,
|
new_template_category.category_type,
|
||||||
TemplateCategoryType::Feature
|
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_category_name = Uuid::new_v4().to_string();
|
||||||
let updated_template_category = authorized_client
|
let updated_template_category = authorized_client
|
||||||
.update_template_category(
|
.update_template_category(
|
||||||
|
|
@ -96,7 +96,7 @@ async fn test_template_category_crud() {
|
||||||
updated_template_category.category_type,
|
updated_template_category.category_type,
|
||||||
TemplateCategoryType::UseCase
|
TemplateCategoryType::UseCase
|
||||||
);
|
);
|
||||||
assert_eq!(updated_template_category.rank, 2);
|
assert_eq!(updated_template_category.priority, 2);
|
||||||
|
|
||||||
let guest_client = localhost_client();
|
let guest_client = localhost_client();
|
||||||
let template_category = guest_client
|
let template_category = guest_client
|
||||||
|
|
@ -111,7 +111,7 @@ async fn test_template_category_crud() {
|
||||||
template_category.category_type,
|
template_category.category_type,
|
||||||
TemplateCategoryType::UseCase
|
TemplateCategoryType::UseCase
|
||||||
);
|
);
|
||||||
assert_eq!(template_category.rank, 2);
|
assert_eq!(template_category.priority, 2);
|
||||||
|
|
||||||
let second_category_name = Uuid::new_v4().to_string();
|
let second_category_name = Uuid::new_v4().to_string();
|
||||||
authorized_client
|
authorized_client
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue