Commit 76ca0dc 1 parent d5da516 commit 76ca0dc Copy full SHA for 76ca0dc
File tree 2 files changed +31
-9
lines changed
2 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,14 @@ extern crate rocket;
19
19
20
20
pub struct CORS ;
21
21
22
+ mod admin;
23
+ mod byond;
24
+ mod connections;
25
+ mod logging;
26
+ mod player;
27
+ mod stickyban;
28
+ mod ticket;
29
+
22
30
#[ rocket:: async_trait]
23
31
impl Fairing for CORS {
24
32
fn info ( & self ) -> Info {
@@ -39,14 +47,6 @@ impl Fairing for CORS {
39
47
}
40
48
}
41
49
42
- mod admin;
43
- mod byond;
44
- mod connections;
45
- mod logging;
46
- mod player;
47
- mod stickyban;
48
- mod ticket;
49
-
50
50
#[ derive( Debug , Deserialize , Serialize , Clone ) ]
51
51
struct TopicConfig {
52
52
host : Option < String > ,
@@ -104,7 +104,8 @@ fn rocket() -> _ {
104
104
player:: index,
105
105
player:: id,
106
106
player:: new_note,
107
- player:: applied_notes
107
+ player:: applied_notes,
108
+ player:: get_playtime
108
109
] ,
109
110
)
110
111
. mount (
Original file line number Diff line number Diff line change @@ -300,6 +300,27 @@ pub async fn create_note(
300
300
}
301
301
}
302
302
303
+ #[ derive( Serialize , FromRow ) ]
304
+ #[ serde( rename_all = "camelCase" ) ]
305
+ pub struct Playtime {
306
+ id : i64 ,
307
+ player_id : i64 ,
308
+ role_id : String ,
309
+ total_minutes : i32 ,
310
+ }
311
+
312
+ #[ get( "/<id>/Playtime" ) ]
313
+ pub async fn get_playtime ( mut db : Connection < Cmdb > , id : i64 ) -> Json < Vec < Playtime > > {
314
+ match query_as ( "SELECT * FROM player_playtime WHERE player_id = ?" )
315
+ . bind ( id)
316
+ . fetch_all ( & mut * * db)
317
+ . await
318
+ {
319
+ Ok ( some) => Json ( some) ,
320
+ Err ( _) => return Json ( Vec :: new ( ) ) ,
321
+ }
322
+ }
323
+
303
324
pub async fn get_player_id ( db : & mut MySqlConnection , ckey : & String ) -> Option < i64 > {
304
325
let player_id: i64 = match query ( "SELECT id FROM players WHERE ckey = ?" )
305
326
. bind ( ckey)
You can’t perform that action at this time.
0 commit comments