Insert an `ip_risk_cache` row with the given `checked_at` offset.
(
db: &sea_orm::DatabaseConnection,
ip: &str,
days_ago: i64,
)
| 355 | |
| 356 | /// Insert an `ip_risk_cache` row with the given `checked_at` offset. |
| 357 | async fn insert_cache( |
| 358 | db: &sea_orm::DatabaseConnection, |
| 359 | ip: &str, |
| 360 | days_ago: i64, |
| 361 | ) { |
| 362 | let checked_at = Utc::now() - ChronoDuration::days(days_ago); |
| 363 | ip_risk_cache::ActiveModel { |
| 364 | ip: Set(ip.to_string()), |
| 365 | asn: Set(None), |
| 366 | as_org: Set(None), |
| 367 | country: Set(None), |
| 368 | region: Set(None), |
| 369 | city: Set(None), |
| 370 | ip_type: Set("unknown".to_string()), |
| 371 | is_proxy: Set(false), |
| 372 | is_vpn: Set(false), |
| 373 | is_hosting: Set(false), |
| 374 | risk_score: Set(None), |
| 375 | risk_level: Set("unknown".to_string()), |
| 376 | is_tor: Set(false), |
| 377 | is_abuser: Set(false), |
| 378 | is_mobile: Set(false), |
| 379 | asn_abuser_score: Set(None), |
| 380 | abuse_email: Set(None), |
| 381 | providers: Set("{}".to_string()), |
| 382 | checked_at: Set(checked_at), |
| 383 | } |
| 384 | .insert(db) |
| 385 | .await |
| 386 | .expect("insert ip_risk_cache"); |
| 387 | } |
| 388 | |
| 389 | #[tokio::test] |
| 390 | async fn cleanup_ip_quality_events_removes_old_rows_and_keeps_recent() { |
no outgoing calls
no test coverage detected