|
|
|
@ -13,12 +13,14 @@ pub fn setup(pool: DbPool) -> Result<(), LemmyError> {
|
|
|
|
|
|
|
|
|
|
let conn = pool.get()?;
|
|
|
|
|
active_counts(&conn);
|
|
|
|
|
update_banned_when_expired(&conn);
|
|
|
|
|
|
|
|
|
|
// On startup, reindex the tables non-concurrently
|
|
|
|
|
// TODO remove this for now, since it slows down startup a lot on lemmy.ml
|
|
|
|
|
reindex_aggregates_tables(&conn, true);
|
|
|
|
|
scheduler.every(1.hour()).run(move || {
|
|
|
|
|
active_counts(&conn);
|
|
|
|
|
update_banned_when_expired(&conn);
|
|
|
|
|
reindex_aggregates_tables(&conn, true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -91,3 +93,13 @@ fn active_counts(conn: &PgConnection) {
|
|
|
|
|
|
|
|
|
|
info!("Done.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Set banned to false after ban expires
|
|
|
|
|
fn update_banned_when_expired(conn: &PgConnection) {
|
|
|
|
|
info!("Updating banned column if it expires ...");
|
|
|
|
|
let update_ban_expires_stmt =
|
|
|
|
|
"update person set banned = false where banned = true and ban_expires < now()";
|
|
|
|
|
sql_query(update_ban_expires_stmt)
|
|
|
|
|
.execute(conn)
|
|
|
|
|
.expect("update banned when expires");
|
|
|
|
|
}
|
|
|
|
|