@@ -7,7 +7,7 @@ use mongodb::{
77} ;
88
99use crate :: {
10- models:: { AccountId , Vote , VoteId } ,
10+ models:: { AccountId , TankId , Vote , VoteId } ,
1111 prelude:: * ,
1212 tankopedia:: vendored:: TANKOPEDIA ,
1313} ;
@@ -22,7 +22,7 @@ impl Votes {
2222 Ok ( Self ( collection) )
2323 }
2424
25- #[ instrument( skip_all, fields( account_id = %vote. id. account_id, tank_id = vote. id. tank_id) ) ]
25+ #[ instrument( skip_all, fields( account_id = %vote. id. account_id, tank_id = % vote. id. tank_id) ) ]
2626 pub async fn insert ( & self , vote : & Vote ) -> Result {
2727 let options = UpdateOptions :: builder ( ) . upsert ( true ) . build ( ) ;
2828 self . 0
@@ -38,8 +38,8 @@ impl Votes {
3838 Ok ( ( ) )
3939 }
4040
41- #[ instrument( skip_all, fields( account_id = %account_id, tank_id = tank_id) ) ]
42- pub async fn delete ( & self , account_id : AccountId , tank_id : u16 ) -> Result {
41+ #[ instrument( skip_all, fields( account_id = %account_id, tank_id = % tank_id) ) ]
42+ pub async fn delete ( & self , account_id : AccountId , tank_id : TankId ) -> Result {
4343 let vote_id = VoteId { account_id, tank_id } ;
4444 self . 0
4545 . delete_one ( doc ! { "_id" : to_document( & vote_id) ? } , None )
@@ -81,7 +81,7 @@ mod tests {
8181 #[ ignore]
8282 async fn get_all_by_account_id_ok ( ) -> Result {
8383 let manager = Db :: open_unittests ( ) . await ?. votes ( ) . await ?;
84- let mut vote = Vote :: new ( 1 , 42 , Rating :: Like ) ;
84+ let mut vote = Vote :: new ( 1 , TankId ( 42 ) , Rating :: Like ) ;
8585 vote. timestamp = vote. timestamp . duration_round ( Duration :: seconds ( 1 ) ) ?;
8686 manager. insert ( & vote) . await ?;
8787
@@ -117,9 +117,9 @@ mod tests {
117117 #[ ignore]
118118 async fn delete_vote_ok ( ) -> Result {
119119 let manager = Db :: open_unittests ( ) . await ?. votes ( ) . await ?;
120- let vote = Vote :: new ( 1 , 42 , Rating :: Like ) ;
120+ let vote = Vote :: new ( 1 , TankId ( 42 ) , Rating :: Like ) ;
121121 manager. insert ( & vote) . await ?;
122- manager. delete ( vote. id . account_id , 42 ) . await ?;
122+ manager. delete ( vote. id . account_id , vote . id . tank_id ) . await ?;
123123 assert ! (
124124 manager
125125 . iter_by_account_id( vote. id. account_id)
0 commit comments