File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ extern crate time;
7
7
8
8
use std:: env;
9
9
use std:: collections:: HashMap ;
10
- use time:: Duration ;
10
+ use std :: time:: Duration ;
11
11
12
12
use cargo_registry:: { VersionDownload , Version , Model } ;
13
13
@@ -17,14 +17,14 @@ static LIMIT: i64 = 1000;
17
17
fn main ( ) {
18
18
let daemon = env:: args ( ) . nth ( 1 ) . as_ref ( ) . map ( |s| & s[ ..] )
19
19
== Some ( "daemon" ) ;
20
- let sleep = env:: args ( ) . nth ( 2 ) . map ( |s| s. parse :: < u32 > ( ) . unwrap ( ) ) ;
20
+ let sleep = env:: args ( ) . nth ( 2 ) . map ( |s| s. parse ( ) . unwrap ( ) ) ;
21
21
loop {
22
22
let conn = postgres:: Connection :: connect ( & env ( "DATABASE_URL" ) [ ..] ,
23
23
& postgres:: SslMode :: None ) . unwrap ( ) ;
24
24
update ( & conn) . unwrap ( ) ;
25
25
drop ( conn) ;
26
26
if daemon {
27
- std:: thread:: sleep_ms ( sleep. unwrap ( ) * 1000 ) ;
27
+ std:: thread:: sleep ( Duration :: new ( sleep. unwrap ( ) , 0 ) ) ;
28
28
} else {
29
29
break
30
30
}
@@ -63,11 +63,12 @@ fn update(conn: &postgres::GenericConnection) -> postgres::Result<()> {
63
63
64
64
fn collect ( tx : & postgres:: Transaction ,
65
65
rows : & mut postgres:: rows:: Rows ) -> postgres:: Result < Option < i32 > > {
66
+ use time:: Duration ;
66
67
67
68
// Anything older than 24 hours ago will be frozen and will not be queried
68
69
// against again.
69
70
let cutoff = time:: now_utc ( ) . to_timespec ( ) ;
70
- let cutoff = cutoff + Duration :: days ( - 1 ) ;
71
+ let cutoff = cutoff + Duration :: days ( 1 ) ;
71
72
72
73
let mut map = HashMap :: new ( ) ;
73
74
for row in rows. iter ( ) {
You can’t perform that action at this time.
0 commit comments