pub async fn check_channel(ctx: &Context, day: NaiveDate) -> Result<()> {
        // check if channel even registered in db
        let sbc = match db::SignupBoardChannel::by_day(ctx, day).await {
            Ok(ch) => ch,
            Err(diesel::NotFound) => return Ok(()),
            Err(e) => return Err(e.into()),
        };

        let count = db::Training::amount_active_by_day(ctx, day).await?;
        if count > 0 {
            return Ok(());
        }

        if let Ok(ch) = ctx.http.get_channel(*sbc.channel().as_u64()).await {
            ch.delete(ctx).await?;
        }

        sbc.delete(ctx).await?;
        Ok(())
    }
// This checks if there are no more trainings for a channel and deletes it
// This will take the db data as reference and not the actual channel
// so if a training is still on the board by accident the channel will be deleted anyway
// If there are trainings left on that day but not on the board by accident the channel
// will stay up (even if empty). A reset should hopefully post the trainings again
This checks if there are no more trainings for a channel and deletes it
This will take the db data as reference and not the actual channel
so if a training is still on the board by accident the channel will be deleted anyway
If there are trainings left on that day but not on the board by accident the channel
will stay up (even if empty). A reset should hopefully post the trainings again
This checks if there are no more trainings for a channel and deletes it This will take the db data as reference and not the actual channel so if a training is still on the board by accident the channel will be deleted anyway If there are trainings left on that day but not on the board by accident the channel will stay up ( even if empty ) . A reset should hopefully post the trainings again
pub async fn check_channel(ctx: &Context, day: NaiveDate) -> Result<()> {
        // check if channel even registered in db
        let sbc = match db::SignupBoardChannel::by_day(ctx, day).await {
            Ok(ch) => ch,
            Err(diesel::NotFound) => return Ok(()),
            Err(e) => return Err(e.into()),
        };
        let count = db::Training::amount_active_by_day(ctx, day).await?;
        if count > 0 {
            return Ok(());
        }
        if let Ok(ch) = ctx.http.get_channel(*sbc.channel().as_u64()).await {
            ch.delete(ctx).await?;
        }
        sbc.delete(ctx).await?;
        Ok(())
    }
pub async fn check_channel ( ctx : & Context , day : NaiveDate ) -> Result < ( ) > { // check if channel even registered in db let sbc = match db :: SignupBoardChannel :: by_day ( ctx , day ) . await { Ok ( ch ) => ch , Err ( diesel :: NotFound ) => return Ok ( ( ) ) , Err ( e ) => return Err ( e . into ( ) ) , } ; let count = db :: Training :: amount_active_by_day ( ctx , day ) . await ? ; if count > 0 { return Ok ( ( ) ) ; } if let Ok ( ch ) = ctx . http . get_channel ( * sbc . channel ( ) . as_u64 ( ) ) . await { ch . delete ( ctx ) . await ? ; } sbc . delete ( ctx ) . await ? ; Ok ( ( ) ) }
This checks if there are no more trainings for a channel and deletes it
This will take the db data as reference and not the actual channel
so if a training is still on the board by accident the channel will be deleted anyway
If there are trainings left on that day but not on the board by accident the channel
will stay up (even if empty).
This checks if there are no more trainings for a channel and deletes it This will take the db data as reference and not the actual channel so if a training is still on the board by accident the channel will be deleted anyway If there are trainings left on that day but not on the board by accident the channel will stay up ( even if empty ) .
ctx
&Context
day
NaiveDate