diff --git a/backend/.sqlx/query-18bdd06f4791c652addb4783f419f5d020c1d23278f583c6be6314768f9bf25a.json b/backend/.sqlx/query-18bdd06f4791c652addb4783f419f5d020c1d23278f583c6be6314768f9bf25a.json new file mode 100644 index 0000000000..e1a56c036a --- /dev/null +++ b/backend/.sqlx/query-18bdd06f4791c652addb4783f419f5d020c1d23278f583c6be6314768f9bf25a.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM group_ WHERE name != 'all'", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "18bdd06f4791c652addb4783f419f5d020c1d23278f583c6be6314768f9bf25a" +} diff --git a/backend/.sqlx/query-fc2ec6fc4e22e46cc35b00503eff1eac35a6fdbc82a634b7eb9da4d7931f3582.json b/backend/.sqlx/query-fc2ec6fc4e22e46cc35b00503eff1eac35a6fdbc82a634b7eb9da4d7931f3582.json deleted file mode 100644 index 145dd54e3d..0000000000 --- a/backend/.sqlx/query-fc2ec6fc4e22e46cc35b00503eff1eac35a6fdbc82a634b7eb9da4d7931f3582.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE queue SET running = false, started_at = null, logs = logs || '\nRestarted job after not receiving job''s ping for too long the ' || now() || '\n\n' WHERE last_ping < now() - ($1 || ' seconds')::interval AND running = true AND job_kind != $2 AND job_kind != $3 AND same_worker = false RETURNING id, workspace_id, last_ping", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "workspace_id", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "last_ping", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Text", - { - "Custom": { - "name": "job_kind", - "kind": { - "Enum": [ - "script", - "preview", - "flow", - "dependencies", - "flowpreview", - "script_hub", - "identity", - "flowdependencies", - "http", - "graphql", - "postgresql", - "noop", - "appdependencies" - ] - } - } - }, - { - "Custom": { - "name": "job_kind", - "kind": { - "Enum": [ - "script", - "preview", - "flow", - "dependencies", - "flowpreview", - "script_hub", - "identity", - "flowdependencies", - "http", - "graphql", - "postgresql", - "noop", - "appdependencies" - ] - } - } - } - ] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "fc2ec6fc4e22e46cc35b00503eff1eac35a6fdbc82a634b7eb9da4d7931f3582" -} diff --git a/backend/windmill-api/src/groups.rs b/backend/windmill-api/src/groups.rs index 0de0a82fab..a6bdf0c903 100644 --- a/backend/windmill-api/src/groups.rs +++ b/backend/windmill-api/src/groups.rs @@ -200,8 +200,20 @@ pub async fn require_is_owner( } } +fn check_nb_of_groups(db: &DB) -> Result<()> { + let nb_groups = sqlx::query_scalar!("SELECT COUNT(*) FROM group_ WHERE name != 'all'",) + .fetch_one(&db) + .await?; + if nb_groups.unwrap_or(0) >= 5 { + return Err(Error::BadRequest( + "You have reached the maximum number of groups without an enterprise license" + .to_string(), + )); + } +} async fn create_group( authed: ApiAuthed, + Extension(db): Extension, Extension(user_db): Extension, Path(w_id): Path, Json(ng): Json, @@ -212,15 +224,7 @@ async fn create_group( #[cfg(not(feature = "enterprise"))] { - let nb_groups = sqlx::query_scalar!("SELECT COUNT(*) FROM group_ WHERE name != 'all'",) - .fetch_one(&mut *tx) - .await?; - if nb_groups.unwrap_or(0) >= 5 { - return Err(Error::BadRequest( - "You have reached the maximum number of groups without an enterprise license" - .to_string(), - )); - } + check_nb_of_groups(&db).await?; } sqlx::query!(