mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 08:04:25 +00:00
exclude demo from per workspace restrictions
This commit is contained in:
@@ -2590,17 +2590,15 @@ pub async fn push<'c, T: Serialize + Send + Sync, R: rsmq_async::RsmqConnection
|
||||
) -> Result<(Uuid, QueueTransaction<'c, R>), Error> {
|
||||
#[cfg(feature = "enterprise")]
|
||||
if *CLOUD_HOSTED {
|
||||
let premium_workspace = sqlx::query_scalar!(
|
||||
"SELECT premium FROM workspace WHERE id = $1",
|
||||
workspace_id
|
||||
)
|
||||
.fetch_one(_db)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
Error::InternalErr(format!(
|
||||
"fetching if {workspace_id} is premium and overquota: {e}"
|
||||
))
|
||||
})?;
|
||||
let premium_workspace =
|
||||
sqlx::query_scalar!("SELECT premium FROM workspace WHERE id = $1", workspace_id)
|
||||
.fetch_one(_db)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
Error::InternalErr(format!(
|
||||
"fetching if {workspace_id} is premium and overquota: {e}"
|
||||
))
|
||||
})?;
|
||||
|
||||
// we track only non flow steps
|
||||
let (workspace_usage, user_usage) = if !matches!(
|
||||
@@ -2617,7 +2615,7 @@ pub async fn push<'c, T: Serialize + Send + Sync, R: rsmq_async::RsmqConnection
|
||||
.fetch_one(_db)
|
||||
.await
|
||||
.map_err(|e| Error::InternalErr(format!("updating usage: {e}")))?;
|
||||
|
||||
|
||||
let user_usage = if !premium_workspace {
|
||||
Some(sqlx::query_scalar!(
|
||||
"INSERT INTO usage (id, is_workspace, month_, usage)
|
||||
@@ -2686,7 +2684,8 @@ pub async fn push<'c, T: Serialize + Send + Sync, R: rsmq_async::RsmqConnection
|
||||
"User {email} has exceeded the free usage limit of {MAX_FREE_EXECS} that applies outside of premium workspaces."
|
||||
)));
|
||||
}
|
||||
if workspace_usage > MAX_FREE_EXECS
|
||||
if workspace_id != "demo"
|
||||
&& workspace_usage > MAX_FREE_EXECS
|
||||
&& !matches!(job_payload, JobPayload::Dependencies { .. })
|
||||
&& !matches!(job_payload, JobPayload::FlowDependencies { .. })
|
||||
&& !matches!(job_payload, JobPayload::AppDependencies { .. })
|
||||
@@ -2707,11 +2706,13 @@ pub async fn push<'c, T: Serialize + Send + Sync, R: rsmq_async::RsmqConnection
|
||||
)));
|
||||
}
|
||||
|
||||
let in_queue_workspace =
|
||||
sqlx::query_scalar!("SELECT COUNT(id) FROM queue WHERE workspace_id = $1", workspace_id)
|
||||
.fetch_one(_db)
|
||||
.await?
|
||||
.unwrap_or(0);
|
||||
let in_queue_workspace = sqlx::query_scalar!(
|
||||
"SELECT COUNT(id) FROM queue WHERE workspace_id = $1",
|
||||
workspace_id
|
||||
)
|
||||
.fetch_one(_db)
|
||||
.await?
|
||||
.unwrap_or(0);
|
||||
|
||||
if in_queue_workspace > MAX_FREE_EXECS.into() {
|
||||
return Err(error::Error::BadRequest(format!(
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
const plans = {
|
||||
Free: [
|
||||
'Users use their individual global free-tier quotas when doing executions in this workspace',
|
||||
'<b>1 000</b> free global executions per-user per month'
|
||||
'<b>1 000</b> free global executions per-user per month',
|
||||
'<b>1 000</b> free executions per workspace per month'
|
||||
],
|
||||
Team: [
|
||||
`<b>$10/mo</b> per seat`,
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { logout } from '$lib/logout'
|
||||
import { userStore, usageStore, workspaceUsageStore, isPremiumStore } from '$lib/stores'
|
||||
import {
|
||||
userStore,
|
||||
usageStore,
|
||||
workspaceUsageStore,
|
||||
isPremiumStore,
|
||||
workspaceStore
|
||||
} from '$lib/stores'
|
||||
import Menu from '../common/menu/MenuV2.svelte'
|
||||
import { USER_SETTINGS_HASH } from './settings'
|
||||
import { isCloudHosted } from '$lib/cloud'
|
||||
@@ -105,9 +111,11 @@
|
||||
<div class="w-full bg-gray-200 h-1">
|
||||
<div class="bg-blue-400 h-1" style="width: {Math.min($usageStore, 1000) / 10}%" />
|
||||
</div>
|
||||
<span class="text-secondary block w-full text-left px-4 py-2 text-sm"
|
||||
>{$workspaceUsageStore}/1000 workspace execs</span
|
||||
>
|
||||
{#if $workspaceStore != 'demo'}
|
||||
<span class="text-secondary block w-full text-left px-4 py-2 text-xs"
|
||||
>{$workspaceUsageStore}/1000 free workspace execs</span
|
||||
>
|
||||
{/if}
|
||||
<div class="w-full bg-gray-200 h-1">
|
||||
<div
|
||||
class="bg-blue-400 h-1"
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { superadmin, userStore, userWorkspaces, workspaceStore } from '$lib/stores'
|
||||
import {
|
||||
isPremiumStore,
|
||||
superadmin,
|
||||
userStore,
|
||||
userWorkspaces,
|
||||
workspaceStore,
|
||||
workspaceUsageStore
|
||||
} from '$lib/stores'
|
||||
import { Building, Plus, Settings } from 'lucide-svelte'
|
||||
|
||||
import Menu from '../common/menu/MenuV2.svelte'
|
||||
@@ -10,6 +17,7 @@
|
||||
import { enterpriseLicense } from '$lib/stores'
|
||||
import MenuButton from './MenuButton.svelte'
|
||||
import { MenuItem } from '@rgossiaux/svelte-headlessui'
|
||||
import { isCloudHosted } from '$lib/cloud'
|
||||
|
||||
export let isCollapsed: boolean = false
|
||||
|
||||
@@ -103,6 +111,31 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if isCloudHosted() && !$isPremiumStore}
|
||||
<div class="py-1" role="none">
|
||||
{#if $workspaceStore != 'demo'}
|
||||
<span class="text-secondary block w-full text-left px-4 py-2 text-xs"
|
||||
>{$workspaceUsageStore}/1000 free workspace execs</span
|
||||
>
|
||||
{/if}
|
||||
<div class="w-full bg-gray-200 h-1">
|
||||
<div class="bg-blue-400 h-1" style="width: {Math.min($workspaceUsageStore, 1000) / 10}%" />
|
||||
</div>
|
||||
{#if $userStore?.is_admin}
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary block font-normal w-full text-left px-4 py-2 text-sm hover:bg-gray-100 hover:text-gray-900"
|
||||
role="menuitem"
|
||||
tabindex="-1"
|
||||
on:click={() => {
|
||||
goto('/workspace_settings?tab=premium')
|
||||
}}
|
||||
>
|
||||
Upgrade
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if $enterpriseLicense}
|
||||
<MultiplayerMenu />
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user