pub async fn load_subscriptions(pool: &PgPool) -> Result<(), sqlx::Error> {
    let mut cm = redis_cm().await.clone();
    let account_keys: Vec<String> = cm.keys("account:*").await.unwrap();
    for key in account_keys {
        let _: () = cm.del(key).await.unwrap();
    }

    let mut rows =
        sqlx::query("SELECT account, array_agg(user_id) FROM subscriptions GROUP BY account")
            .fetch(pool);

    while let Some(row) = rows.try_next().await? {
        let k = row.get::<&[u8], _>(0).to_base58check(1);
        let v: Vec<i64> = row.get(1);
        let key = format!("account:{}", k);
        let _: () = cm.sadd(key, v).await.unwrap();
    }

    Ok(())
}
/// Preloads all subscriptions from Postgres to Redis.
/// For each subscriber account there are a set of Telegram user IDs.
/// Many users can subscribe to updates for one account.
Preloads all subscriptions from Postgres to Redis.
For each subscriber account there are a set of Telegram user IDs.
Many users can subscribe to updates for one account.
Preloads all subscriptions from Postgres to Redis . For each subscriber account there are a set of Telegram user IDs . Many users can subscribe to updates for one account .
pub async fn load_subscriptions(pool: &PgPool) -> Result<(), sqlx::Error> {
    let mut cm = redis_cm().await.clone();
    let account_keys: Vec<String> = cm.keys("account:*").await.unwrap();
    for key in account_keys {
        let _: () = cm.del(key).await.unwrap();
    }
    let mut rows =
        sqlx::query("SELECT account, array_agg(user_id) FROM subscriptions GROUP BY account")
            .fetch(pool);
    while let Some(row) = rows.try_next().await? {
        let k = row.get::<&[u8], _>(0).to_base58check(1);
        let v: Vec<i64> = row.get(1);
        let key = format!("account:{}", k);
        let _: () = cm.sadd(key, v).await.unwrap();
    }
    Ok(())
}
pub async fn load_subscriptions ( pool : & PgPool ) -> Result < ( ) , sqlx :: Error > { let mut cm = redis_cm ( ) . await . clone ( ) ; let account_keys : Vec < String > = cm . keys ( " " ) . await . unwrap ( ) ; for key in account_keys { let _ : ( ) = cm . del ( key ) . await . unwrap ( ) ; } let mut rows = sqlx :: query ( " " ) . fetch ( pool ) ; while let Some ( row ) = rows . try_next ( ) . await ? { let k = row . get :: < & [ u8 ] , _ > ( 0 ) . to_base58check ( 1 ) ; let v : Vec < i64 > = row . get ( 1 ) ; let key = format ! ( " " k ) ; let _ : ( ) = cm . sadd ( key , v ) . await . unwrap ( ) ; } Ok ( ( ) ) }
Preloads all subscriptions from Postgres to Redis.
Preloads all subscriptions from Postgres to Redis .
pool
&PgPool
pool
&PgPool