select count(*) from ml_mail_jobs where mail_class_id = :class_id and state = 'pending'