email quotas only apply to top-level job

This commit is contained in:
Ruben Fiszel
2024-11-25 16:20:55 +01:00
parent 1dbcae953d
commit a268bbf2cd

View File

@@ -1791,7 +1791,7 @@ async fn handle_queued_job(
}
#[cfg(any(not(feature = "enterprise"), feature = "sqlx"))]
if job.created_by.starts_with("email-") {
if job.parent_job.is_none() && job.created_by.starts_with("email-") {
let daily_count = sqlx::query!(
"SELECT value FROM metrics WHERE id = 'email_trigger_usage' AND created_at > NOW() - INTERVAL '1 day' ORDER BY created_at DESC LIMIT 1"
).fetch_optional(db).await?.map(|x| serde_json::from_value::<i64>(x.value).unwrap_or(1));