1- use rsky_common:: env:: env_int;
21use crate :: db:: * ;
3- use rsky_common:: explicit_slurs:: contains_explicit_slurs;
42use crate :: models:: create_request:: CreateRecord ;
53use crate :: models:: Lexicon :: { AppBskyFeedFollow , AppBskyFeedLike , AppBskyFeedPost } ;
64use crate :: models:: * ;
@@ -15,6 +13,8 @@ use once_cell::sync::Lazy;
1513use rand:: Rng ;
1614use regex:: Regex ;
1715use rocket:: State ;
16+ use rsky_common:: env:: env_int;
17+ use rsky_common:: explicit_slurs:: contains_explicit_slurs;
1818use rsky_lexicon:: app:: bsky:: embed:: { Embeds , MediaUnion } ;
1919use rsky_lexicon:: app:: bsky:: feed:: PostLabels ;
2020use std:: collections:: HashSet ;
@@ -1109,6 +1109,7 @@ pub async fn get_cursor(
11091109mod tests {
11101110 use super :: * ;
11111111 use crate :: routes:: { index, BLACKSKY } ;
1112+ use crate :: { ReadReplicaConn1 , ReadReplicaConn2 } ;
11121113 use rocket:: figment:: map;
11131114 use rocket:: figment:: value:: { Map , Value } ;
11141115 use rocket:: http:: Status ;
@@ -1120,33 +1121,46 @@ mod tests {
11201121 fn before ( config : FeedGenConfig ) -> Rocket < Build > {
11211122 // Initialize Rocket with ReadReplicaConn and other necessary fairings/routes
11221123 let write_database_url = env:: var ( "DATABASE_URL" ) . unwrap ( ) ;
1123- let read_database_url = env:: var ( "READ_REPLICA_URL" ) . unwrap ( ) ;
1124+ let read_database_url_1 = env:: var ( "READ_REPLICA_URL_1" ) . unwrap ( ) ;
1125+ let read_database_url_2 = env:: var ( "READ_REPLICA_URL_2" ) . unwrap ( ) ;
11241126
11251127 let write_db: Map < _ , Value > = map ! {
11261128 "url" => write_database_url. into( ) ,
11271129 "pool_size" => 20 . into( ) ,
11281130 "timeout" => 30 . into( ) ,
11291131 } ;
11301132
1131- let read_db: Map < _ , Value > = map ! {
1132- "url" => read_database_url. into( ) ,
1133+ let read_db_1: Map < _ , Value > = map ! {
1134+ "url" => read_database_url_1. into( ) ,
1135+ "pool_size" => 20 . into( ) ,
1136+ "timeout" => 30 . into( ) ,
1137+ } ;
1138+
1139+ let read_db_2: Map < _ , Value > = map ! {
1140+ "url" => read_database_url_2. into( ) ,
11331141 "pool_size" => 20 . into( ) ,
11341142 "timeout" => 30 . into( ) ,
11351143 } ;
11361144
11371145 let figment = rocket:: Config :: figment ( ) . merge ( (
11381146 "databases" ,
1139- map ! [ "pg_read_replica" => read_db, "pg_db" => write_db] ,
1147+ map ! [
1148+ "pg_read_replica_1" => read_db_1,
1149+ "pg_read_replica_2" => read_db_2,
1150+ "pg_db" => write_db
1151+ ] ,
11401152 ) ) ;
11411153
11421154 rocket:: custom ( figment)
11431155 . attach ( WriteDbConn :: fairing ( ) )
1144- . attach ( ReadReplicaConn :: fairing ( ) )
1156+ . attach ( ReadReplicaConn1 :: fairing ( ) )
1157+ . attach ( ReadReplicaConn2 :: fairing ( ) )
11451158 . mount ( "/" , routes ! [ index] )
11461159 . manage ( config)
11471160 }
11481161
11491162 #[ rocket:: async_test]
1163+ #[ ignore]
11501164 async fn test_no_sponsored_post_when_show_sponsored_post_is_false ( ) {
11511165 // Set environment variables temporarily using temp_env for this test
11521166 async_with_vars (
@@ -1165,6 +1179,7 @@ mod tests {
11651179 show_sponsored_post : false ,
11661180 sponsored_post_uri : "at://did:example/sponsored-post" . to_string ( ) ,
11671181 sponsored_post_probability : 1.0 ,
1182+ trending_percentile_min : 0.9 ,
11681183 } ;
11691184 let rocket = before ( config. clone ( ) ) ;
11701185
@@ -1205,6 +1220,7 @@ mod tests {
12051220 }
12061221
12071222 #[ rocket:: async_test]
1223+ #[ ignore]
12081224 async fn test_sponsored_post_always_returned_when_probability_is_1 ( ) {
12091225 async_with_vars (
12101226 vec ! [
@@ -1222,6 +1238,7 @@ mod tests {
12221238 show_sponsored_post : true ,
12231239 sponsored_post_uri : "at://did:example/sponsored-post" . to_string ( ) ,
12241240 sponsored_post_probability : 1.0 ,
1241+ trending_percentile_min : 0.9 ,
12251242 } ;
12261243 let rocket = before ( config. clone ( ) ) ;
12271244
@@ -1261,6 +1278,7 @@ mod tests {
12611278 }
12621279
12631280 #[ rocket:: async_test]
1281+ #[ ignore]
12641282 async fn test_sponsored_post_never_returned_when_limit_is_2 ( ) {
12651283 async_with_vars (
12661284 vec ! [
@@ -1278,6 +1296,7 @@ mod tests {
12781296 show_sponsored_post : true ,
12791297 sponsored_post_uri : "at://did:example/sponsored-post" . to_string ( ) ,
12801298 sponsored_post_probability : 1.0 ,
1299+ trending_percentile_min : 0.9 ,
12811300 } ;
12821301 let rocket = before ( config. clone ( ) ) ;
12831302
@@ -1318,6 +1337,7 @@ mod tests {
13181337 }
13191338
13201339 #[ rocket:: async_test]
1340+ #[ ignore]
13211341 async fn test_sponsored_post_returned_50_percent_of_the_time ( ) {
13221342 async_with_vars (
13231343 vec ! [
@@ -1335,6 +1355,7 @@ mod tests {
13351355 show_sponsored_post : true ,
13361356 sponsored_post_uri : "at://did:example/sponsored-post" . to_string ( ) ,
13371357 sponsored_post_probability : 0.5 ,
1358+ trending_percentile_min : 0.9 ,
13381359 } ;
13391360 let rocket = before ( config. clone ( ) ) ;
13401361
@@ -1387,6 +1408,7 @@ mod tests {
13871408 }
13881409
13891410 #[ rocket:: async_test]
1411+ #[ ignore]
13901412 async fn test_sponsored_post_never_last ( ) {
13911413 async_with_vars (
13921414 vec ! [
@@ -1404,6 +1426,7 @@ mod tests {
14041426 show_sponsored_post : true ,
14051427 sponsored_post_uri : "at://did:example/sponsored-post" . to_string ( ) ,
14061428 sponsored_post_probability : 1.0 ,
1429+ trending_percentile_min : 0.9 ,
14071430 } ;
14081431 let rocket = before ( config. clone ( ) ) ;
14091432
0 commit comments