mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 16:02:10 +00:00
remove quotas for premium workspaces
This commit is contained in:
@@ -0,0 +1 @@
|
||||
-- Add down migration script here
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Add up migration script here
|
||||
ALTER TABLE workspace ADD COLUMN premium BOOLEAN NOT NULL DEFAULT false;
|
||||
+22
-15
@@ -1006,22 +1006,28 @@ pub async fn push<'c>(
|
||||
let args_json = args.map(serde_json::Value::Object);
|
||||
let job_id: Uuid = Ulid::new().into();
|
||||
|
||||
let rate_limiting_queue = sqlx::query_scalar!(
|
||||
"SELECT COUNT(id) FROM queue WHERE created_by = $1 AND workspace_id = $2",
|
||||
user,
|
||||
workspace_id
|
||||
)
|
||||
.fetch_one(&mut tx)
|
||||
.await?;
|
||||
let premium_workspace =
|
||||
sqlx::query_scalar!("SELECT premium FROM workspace WHERE id = $1", workspace_id)
|
||||
.fetch_one(&mut tx)
|
||||
.await?;
|
||||
|
||||
if let Some(nb_jobs) = rate_limiting_queue {
|
||||
if nb_jobs > MAX_NB_OF_JOBS_IN_Q_PER_USER {
|
||||
return Err(error::Error::ExecutionErr(format!(
|
||||
if !premium_workspace && std::env::var("CLOUD_HOSTED").is_ok() {
|
||||
let rate_limiting_queue = sqlx::query_scalar!(
|
||||
"SELECT COUNT(id) FROM queue WHERE created_by = $1 AND workspace_id = $2",
|
||||
user,
|
||||
workspace_id
|
||||
)
|
||||
.fetch_one(&mut tx)
|
||||
.await?;
|
||||
|
||||
if let Some(nb_jobs) = rate_limiting_queue {
|
||||
if nb_jobs > MAX_NB_OF_JOBS_IN_Q_PER_USER {
|
||||
return Err(error::Error::ExecutionErr(format!(
|
||||
"You have exceeded the number of authorized elements of queue at any given time: {}", MAX_NB_OF_JOBS_IN_Q_PER_USER)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let rate_limiting_duration = sqlx::query_scalar!(
|
||||
let rate_limiting_duration = sqlx::query_scalar!(
|
||||
"SELECT SUM(duration) FROM completed_job WHERE created_by = $1 AND created_at > NOW() - INTERVAL '1200 seconds' AND workspace_id = $2",
|
||||
user,
|
||||
workspace_id
|
||||
@@ -1029,10 +1035,11 @@ pub async fn push<'c>(
|
||||
.fetch_one(&mut tx)
|
||||
.await?;
|
||||
|
||||
if let Some(sum_duration) = rate_limiting_duration {
|
||||
if sum_duration > MAX_DURATION_LAST_1200 {
|
||||
return Err(error::Error::ExecutionErr(format!(
|
||||
if let Some(sum_duration) = rate_limiting_duration {
|
||||
if sum_duration > MAX_DURATION_LAST_1200 {
|
||||
return Err(error::Error::ExecutionErr(format!(
|
||||
"You have exceeded the scripts cumulative duration limit over the last 20m which is: {}", MAX_DURATION_LAST_1200)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ struct Workspace {
|
||||
name: String,
|
||||
owner: String,
|
||||
domain: Option<String>,
|
||||
deleted: bool
|
||||
deleted: bool,
|
||||
premium: bool
|
||||
}
|
||||
|
||||
#[derive(FromRow, Serialize, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user