Skip to content

Commit

Permalink
Workload main language (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir authored Jul 2, 2024
1 parent 98dd8ba commit 5e8b167
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions frontend/webapp/utils/constants/programming.languages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ManagedSource } from "@/types/sources";
import { ManagedSource } from '@/types/sources';

const BASE_URL = 'https://d1n7d4xz7fr8b4.cloudfront.net/';

Expand Down Expand Up @@ -48,10 +48,9 @@ export const LANGUAGES_COLORS: Record<WORKLOAD_PROGRAMMING_LANGUAGES, string> =
export const getMainContainerLanguage = (
source: ManagedSource
): WORKLOAD_PROGRAMMING_LANGUAGES => {

const ia = source?.instrumented_application_details;
if(!ia) {
if(source?.number_of_running_instances > 0) {
if (!ia) {
if (source?.number_of_running_instances > 0) {
return WORKLOAD_PROGRAMMING_LANGUAGES.PROCESSING;
} else {
return WORKLOAD_PROGRAMMING_LANGUAGES.NO_RUNNING_PODS;
Expand All @@ -64,20 +63,19 @@ export const getMainContainerLanguage = (
}

// we will filter out the ignored languages as we don't want to account them in the main language
const notIgnoredLanguages = languages?.filter(
const noneIgnoredLanguages = languages.filter(
(container) => container.language !== 'ignored'
);
if (notIgnoredLanguages.length === 0) {
if (noneIgnoredLanguages.length === 0) {
return WORKLOAD_PROGRAMMING_LANGUAGES.NO_CONTAINERS;
} else {
// find the first container with valid language
const mainContainer = languages?.find(
(container) =>
container.language !== 'default' && container.language !== 'unknown'
);
if (!mainContainer) {
return languages[0].language as WORKLOAD_PROGRAMMING_LANGUAGES; // no valid language found, return the first one
}
return mainContainer.language as WORKLOAD_PROGRAMMING_LANGUAGES;
}

// find the first container with valid language
const mainContainer = noneIgnoredLanguages.find(
(container) => container.language !== 'unknown'
);
if (!mainContainer) {
return WORKLOAD_PROGRAMMING_LANGUAGES.UNKNOWN; // no valid language found, return the first one
}
return mainContainer.language as WORKLOAD_PROGRAMMING_LANGUAGES;
};

0 comments on commit 5e8b167

Please sign in to comment.