@@ -24,14 +24,7 @@ async fn main() {
24
24
match load_contest ( & url) . await {
25
25
Ok ( contests) => {
26
26
for contest in contests {
27
- match AtCoderClient :: new ( & username, & password) . await {
28
- Ok ( client) => {
29
- finish_one_contest ( & url, & contest. id , client) . await ;
30
- }
31
- Err ( e) => {
32
- error ! ( "Failed to login to AtCoder: {:?}" , e) ;
33
- }
34
- }
27
+ finish_one_contest ( & url, & contest. id , & username, & password) . await ;
35
28
}
36
29
}
37
30
Err ( e) => {
@@ -42,10 +35,10 @@ async fn main() {
42
35
}
43
36
}
44
37
45
- async fn finish_one_contest ( url : & str , contest_id : & str , client : AtCoderClient ) {
38
+ async fn finish_one_contest ( url : & str , contest_id : & str , username : & str , password : & str ) {
46
39
loop {
47
40
info ! ( "Starting {}" , contest_id) ;
48
- match crawl_one_contest ( url, contest_id, client . clone ( ) ) . await {
41
+ match crawl_one_contest ( url, contest_id, username , password ) . await {
49
42
Ok ( _) => {
50
43
info ! ( "Finished {}" , contest_id) ;
51
44
return ;
@@ -58,8 +51,14 @@ async fn finish_one_contest(url: &str, contest_id: &str, client: AtCoderClient)
58
51
}
59
52
}
60
53
61
- async fn crawl_one_contest ( url : & str , contest_id : & str , client : AtCoderClient ) -> Result < ( ) > {
54
+ async fn crawl_one_contest (
55
+ url : & str ,
56
+ contest_id : & str ,
57
+ username : & str ,
58
+ password : & str ,
59
+ ) -> Result < ( ) > {
62
60
let db = initialize_pool ( url) . await ?;
61
+ let client = AtCoderClient :: new ( username, password) . await ?;
63
62
let crawler = WholeContestCrawler :: new ( db, client. clone ( ) , contest_id) ;
64
63
crawler. crawl ( ) . await ?;
65
64
Ok ( ( ) )
0 commit comments