@@ -6,8 +6,8 @@ use chrono::SecondsFormat;
6
6
use crates_io_worker:: BackgroundJob ;
7
7
use diesel:: dsl:: IntervalDsl ;
8
8
use diesel:: {
9
- dsl:: now, BoolExpressionMethods , ExpressionMethods , NullableExpressionMethods , PgConnection ,
10
- QueryDsl , QueryResult , RunQueryDsl , SelectableHelper ,
9
+ dsl:: now, ExpressionMethods , NullableExpressionMethods , PgConnection , QueryDsl , QueryResult ,
10
+ RunQueryDsl , SelectableHelper ,
11
11
} ;
12
12
use std:: sync:: Arc ;
13
13
@@ -89,15 +89,13 @@ pub fn find_tokens_expiring_within_days(
89
89
) -> QueryResult < Vec < ApiToken > > {
90
90
api_tokens:: table
91
91
. filter ( api_tokens:: revoked. eq ( false ) )
92
+ . filter ( api_tokens:: expired_at. is_not_null ( ) )
93
+ // Ignore already expired tokens
94
+ . filter ( api_tokens:: expired_at. assume_not_null ( ) . gt ( now) )
92
95
. filter (
93
96
api_tokens:: expired_at
94
- . is_not_null ( )
95
- . and ( api_tokens:: expired_at. assume_not_null ( ) . gt ( now) ) // Ignore already expired tokens
96
- . and (
97
- api_tokens:: expired_at
98
- . assume_not_null ( )
99
- . lt ( now + days_until_expiry. num_days ( ) . day ( ) ) ,
100
- ) ,
97
+ . assume_not_null ( )
98
+ . lt ( now + days_until_expiry. num_days ( ) . day ( ) ) ,
101
99
)
102
100
. filter ( api_tokens:: expiry_notification_at. is_null ( ) )
103
101
. select ( ApiToken :: as_select ( ) )
0 commit comments