chore(api): apply rustfmt across modules and tests
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
6c1357ec4d
commit
a4ef6ca49e
@@ -2,9 +2,7 @@ use sqlx::{PgConnection, PgExecutor};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::error::{ApiError, ApiResult};
|
||||
use crate::models::{
|
||||
CollectiveGroup, GroupBuyingActivity, COLLECTIVE_GROUP_COLUMNS,
|
||||
};
|
||||
use crate::models::{CollectiveGroup, GroupBuyingActivity, COLLECTIVE_GROUP_COLUMNS};
|
||||
|
||||
use super::dto::{ActivityInput, ActivityView, OpenGroupView};
|
||||
|
||||
@@ -89,10 +87,7 @@ pub async fn get_own<'e, E: PgExecutor<'e>>(
|
||||
.ok_or_else(|| ApiError::NotFound("group-buying activity".into()))
|
||||
}
|
||||
|
||||
pub async fn get_by_id<'e, E: PgExecutor<'e>>(
|
||||
exec: E,
|
||||
id: Uuid,
|
||||
) -> ApiResult<GroupBuyingActivity> {
|
||||
pub async fn get_by_id<'e, E: PgExecutor<'e>>(exec: E, id: Uuid) -> ApiResult<GroupBuyingActivity> {
|
||||
sqlx::query_as::<_, GroupBuyingActivity>(
|
||||
"SELECT id, shop_id, sku_id, name, description, image, group_price_minor, currency,
|
||||
required_members, starts_at, ends_at, group_lifetime_hours, enabled,
|
||||
@@ -170,12 +165,11 @@ pub async fn update(
|
||||
}
|
||||
|
||||
pub async fn delete(tx: &mut PgConnection, shop_id: Uuid, id: Uuid) -> ApiResult<()> {
|
||||
let result =
|
||||
sqlx::query("DELETE FROM group_buying_activities WHERE id = $1 AND shop_id = $2")
|
||||
.bind(id)
|
||||
.bind(shop_id)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
let result = sqlx::query("DELETE FROM group_buying_activities WHERE id = $1 AND shop_id = $2")
|
||||
.bind(id)
|
||||
.bind(shop_id)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(ApiError::NotFound("group-buying activity".into()));
|
||||
}
|
||||
@@ -232,10 +226,7 @@ pub async fn open_groups_for_activities(
|
||||
}
|
||||
|
||||
/// Joining only reads the group: a seat is claimed at payment, not checkout.
|
||||
pub async fn get_group<'e, E: PgExecutor<'e>>(
|
||||
exec: E,
|
||||
id: Uuid,
|
||||
) -> ApiResult<CollectiveGroup> {
|
||||
pub async fn get_group<'e, E: PgExecutor<'e>>(exec: E, id: Uuid) -> ApiResult<CollectiveGroup> {
|
||||
sqlx::query_as::<_, CollectiveGroup>(&format!(
|
||||
"SELECT {COLLECTIVE_GROUP_COLUMNS} FROM collective_groups WHERE id = $1"
|
||||
))
|
||||
@@ -262,11 +253,13 @@ pub async fn insert_group(
|
||||
|
||||
/// Record which pending order opened the group.
|
||||
pub async fn set_leader(tx: &mut PgConnection, group_id: Uuid, order_id: Uuid) -> ApiResult<()> {
|
||||
sqlx::query("UPDATE collective_groups SET leader_order_id = $2, updated_at = now() WHERE id = $1")
|
||||
.bind(group_id)
|
||||
.bind(order_id)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"UPDATE collective_groups SET leader_order_id = $2, updated_at = now() WHERE id = $1",
|
||||
)
|
||||
.bind(group_id)
|
||||
.bind(order_id)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -300,7 +293,11 @@ pub async fn insert_member(
|
||||
}
|
||||
|
||||
/// One paid seat: increment and become successful exactly at capacity.
|
||||
pub async fn claim_seat(tx: &mut PgConnection, group_id: Uuid, required: i32) -> ApiResult<CollectiveGroup> {
|
||||
pub async fn claim_seat(
|
||||
tx: &mut PgConnection,
|
||||
group_id: Uuid,
|
||||
required: i32,
|
||||
) -> ApiResult<CollectiveGroup> {
|
||||
Ok(sqlx::query_as::<_, CollectiveGroup>(&format!(
|
||||
"UPDATE collective_groups
|
||||
SET paid_member_count = paid_member_count + 1,
|
||||
|
||||
Reference in New Issue
Block a user