File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1
1
use super :: error:: { EntityApiErrorKind , Error } ;
2
+ use crate :: user;
2
3
use chrono:: Utc ;
3
4
use entity:: {
4
5
coachees, coaches,
@@ -10,7 +11,7 @@ use sea_orm::{
10
11
QuerySelect , QueryTrait , Set ,
11
12
} ;
12
13
use serde:: ser:: { Serialize , SerializeStruct , Serializer } ;
13
-
14
+ use slugify :: slugify ;
14
15
use log:: * ;
15
16
16
17
pub async fn create (
@@ -23,11 +24,15 @@ pub async fn create(
23
24
) ;
24
25
25
26
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( ) ) ;
26
30
27
31
let coaching_relationship_active_model: ActiveModel = ActiveModel {
28
32
organization_id : Set ( coaching_relationship_model. organization_id ) ,
29
33
coach_id : Set ( coaching_relationship_model. coach_id ) ,
30
34
coachee_id : Set ( coaching_relationship_model. coachee_id ) ,
35
+ slug : Set ( slug) ,
31
36
created_at : Set ( now. into ( ) ) ,
32
37
updated_at : Set ( now. into ( ) ) ,
33
38
..Default :: default ( )
You can’t perform that action at this time.
0 commit comments