From 650b5f22ad9b8818e0190821b9d1d428bc7eb64a Mon Sep 17 00:00:00 2001 From: Dylan Decrulle Date: Mon, 25 Nov 2024 13:34:23 +0100 Subject: [PATCH] feat: add env var RUNNING_TIME_THRESHOLD #846 --- web/.env | 6 ++++++ web/src/env.ts | 13 +++++++------ .../MyServicesCard/MyServicesCard.tsx | 3 ++- web/src/vite-env.d.ts | 1 + 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/web/.env b/web/.env index 62c225a5e..14ebf5124 100644 --- a/web/.env +++ b/web/.env @@ -783,6 +783,12 @@ QUOTA_WARNING_THRESHOLD=75% # QUOTA_CRITICAL_THRESHOLD=95% +# This parameter defines the threshold for displaying a service's runtime as a key metric. +# The value is expressed in milliseconds. By default it is set to 7 * 24 * 3600 * 1000, +# it means any service running for 7 days (7 days * 24 hours * 3600 seconds * 1000 milliseconds) +# will have its runtime prominently displayed on the "My Services" page. +RUNNING_TIME_THRESHOLD=604800000 + # This parameter controls if the configurations tabs should be expanded by default # when the user navigates to the launcher page: # https://github.com/InseeFrLab/onyxia/assets/6702424/a1c5597e-82e5-4532-8a9f-ed3ab7cc1d45 diff --git a/web/src/env.ts b/web/src/env.ts index f16da1f42..ee5b3b27f 100644 --- a/web/src/env.ts +++ b/web/src/env.ts @@ -114,9 +114,9 @@ export const { env, injectTransferableEnvsInQueryParams } = createParsedEnvs([ } }, { - envName: "SPLASHSCREEN_LOGO_SCALE_FACTOR", - isUsedInKeycloakTheme: false, - validateAndParseOrGetDefault: ({ envValue, envName }) => { + "envName": "SPLASHSCREEN_LOGO_SCALE_FACTOR", + "isUsedInKeycloakTheme": false, + "validateAndParseOrGetDefault": ({ envValue, envName }) => { assert(envValue !== "Should have default in .env"); const parsedValue = Number(envValue); @@ -1119,9 +1119,10 @@ export const { env, injectTransferableEnvsInQueryParams } = createParsedEnvs([ } }, { - envName: "SERVICE_CONFIGURATION_EXPANDED_BY_DEFAULT", - isUsedInKeycloakTheme: false, - validateAndParseOrGetDefault: ({ envValue, envName }) => { + "envName": "SERVICE_CONFIGURATION_EXPANDED_BY_DEFAULT", + "isUsedInKeycloakTheme": false, + "validateAndParseOrGetDefault": ({ envValue, envName }) => { + const possibleValues = ["true", "false"]; assert( diff --git a/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx b/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx index 319862d11..d5053bfee 100644 --- a/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx +++ b/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx @@ -21,8 +21,9 @@ import type { Service } from "core/usecases/serviceManagement"; import { assert, type Equals } from "tsafe/assert"; import { TextField, TextFieldProps } from "onyxia-ui/TextField"; import MuiLink from "@mui/material/Link"; +import { env } from "env"; -const runningTimeThreshold = 7 * 24 * 3600 * 1000; +const runningTimeThreshold = env.RUNNING_TIME_THRESHOLD; function getDoesHaveBeenRunningForTooLong(params: { startTime: number }): boolean { const { startTime } = params; diff --git a/web/src/vite-env.d.ts b/web/src/vite-env.d.ts index f53f9c4eb..15093b55f 100644 --- a/web/src/vite-env.d.ts +++ b/web/src/vite-env.d.ts @@ -52,6 +52,7 @@ type ImportMetaEnv = { SAMPLE_DATASET_URL: string QUOTA_WARNING_THRESHOLD: string QUOTA_CRITICAL_THRESHOLD: string + RUNNING_TIME_THRESHOLD: string SERVICE_CONFIGURATION_EXPANDED_BY_DEFAULT: string S3_DOCUMENTATION_LINK: string VAULT_DOCUMENTATION_LINK: string