Skip to content

Commit 316276f

Browse files
committed
generate slugs for coaching relationships
1 parent d7366e0 commit 316276f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

entity_api/src/coaching_relationship.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::error::{EntityApiErrorKind, Error};
2+
use crate::user;
23
use chrono::Utc;
34
use entity::{
45
coachees, coaches,
@@ -10,7 +11,7 @@ use sea_orm::{
1011
QuerySelect, QueryTrait, Set,
1112
};
1213
use serde::ser::{Serialize, SerializeStruct, Serializer};
13-
14+
use slugify::slugify;
1415
use log::*;
1516

1617
pub async fn create(
@@ -23,11 +24,15 @@ pub async fn create(
2324
);
2425

2526
let now = Utc::now();
27+
let coach = user::find_by_id(db, coaching_relationship_model.coach_id).await?;
28+
let coachee = user::find_by_id(db, coaching_relationship_model.coachee_id).await?;
29+
let slug = slugify!(format!("{} {}", coach.first_name, coachee.first_name).as_str());
2630

2731
let coaching_relationship_active_model: ActiveModel = ActiveModel {
2832
organization_id: Set(coaching_relationship_model.organization_id),
2933
coach_id: Set(coaching_relationship_model.coach_id),
3034
coachee_id: Set(coaching_relationship_model.coachee_id),
35+
slug: Set(slug),
3136
created_at: Set(now.into()),
3237
updated_at: Set(now.into()),
3338
..Default::default()

0 commit comments

Comments
 (0)