From 20dcce1a4f45d71f0a8cf25b54d9d0aae39b5b66 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Tue, 23 Apr 2024 14:41:53 -0400 Subject: [PATCH] fix(graphql): query target nodes by targets' IDs rather than connectUrls (#1245) --- .../AllTargetsArchivedRecordingsTable.tsx | 6 ++-- .../AutomatedAnalysisCard.tsx | 26 ++++++++-------- src/app/RecordingMetadata/BulkEditLabels.tsx | 6 ++-- .../Recordings/ArchivedRecordingsTable.tsx | 10 +++---- src/app/Shared/Services/Api.service.tsx | 30 +++++++++---------- src/app/Topology/Entity/EntityDetails.tsx | 14 ++++----- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx index 5bfb80944..0b2c2e47a 100644 --- a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx +++ b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx @@ -223,8 +223,8 @@ export const AllTargetsArchivedRecordingsTable: React.FC( - `query ArchiveCountForTarget($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + `query ArchiveCountForTarget($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { archivedRecordings { data { @@ -248,7 +248,7 @@ export const AllTargetsArchivedRecordingsTable: React.FC { setArchivesForTargets((old) => { diff --git a/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx b/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx index ee43d593b..02a1bd638 100644 --- a/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx +++ b/src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx @@ -173,12 +173,12 @@ export const AutomatedAnalysisCard: DashboardCardFC // name: 'automated-analysis'; label: 'origin=automated-analysis' // Query NEEDS 'state' so that isActiveRecording(result) is valid const queryActiveRecordings = React.useCallback( - (connectUrl: string) => { + (targetId: number) => { /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ return context.api.graphql( ` - query ActiveRecordingsForAutomatedAnalysis($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + query ActiveRecordingsForAutomatedAnalysis($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { activeRecordings(filter: { name: "${automatedAnalysisRecordingName}", @@ -200,18 +200,18 @@ export const AutomatedAnalysisCard: DashboardCardFC } } }`, - { connectUrl }, + { id: targetId }, ); }, [context.api], ); const queryArchivedRecordings = React.useCallback( - (connectUrl: string) => { + (targetId: number) => { /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ return context.api.graphql( - `query ArchivedRecordingsForAutomatedAnalysis($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + `query ArchivedRecordingsForAutomatedAnalysis($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { archivedRecordings { data { @@ -231,7 +231,7 @@ export const AutomatedAnalysisCard: DashboardCardFC } } }`, - { connectUrl }, + { id: targetId }, ); }, [context.api], @@ -300,8 +300,8 @@ export const AutomatedAnalysisCard: DashboardCardFC // try generating report on cached or archived recordings const handleEmptyRecordings = React.useCallback( - (connectUrl: string) => { - const cachedReportAnalysis = context.reports.getCachedAnalysisReport(connectUrl); + (target: Target) => { + const cachedReportAnalysis = context.reports.getCachedAnalysisReport(target.connectUrl); if (cachedReportAnalysis.report.length > 0) { setReport(automatedAnalysisRecordingName); setUsingCachedReport(true); @@ -310,7 +310,7 @@ export const AutomatedAnalysisCard: DashboardCardFC setIsLoading(false); } else { addSubscription( - queryArchivedRecordings(connectUrl) + queryArchivedRecordings(target.id!) .pipe( first(), map((v) => v.data.targetNodes[0].target.archivedRecordings.data as ArchivedRecording[]), @@ -355,7 +355,7 @@ export const AutomatedAnalysisCard: DashboardCardFC ) .subscribe((target: Target) => { addSubscription( - queryActiveRecordings(target.connectUrl) + queryActiveRecordings(target.id!) .pipe( first(), tap((resp) => { @@ -395,7 +395,7 @@ export const AutomatedAnalysisCard: DashboardCardFC if (isAuthFail(err.message)) { handleStateErrors(authFailMessage); } else { - handleEmptyRecordings(target.connectUrl); + handleEmptyRecordings(target); } }, }), diff --git a/src/app/RecordingMetadata/BulkEditLabels.tsx b/src/app/RecordingMetadata/BulkEditLabels.tsx index a89f956d7..9d5d57873 100644 --- a/src/app/RecordingMetadata/BulkEditLabels.tsx +++ b/src/app/RecordingMetadata/BulkEditLabels.tsx @@ -189,8 +189,8 @@ export const BulkEditLabels: React.FC = ({ filter((target) => !!target), concatMap((target: Target) => context.api.graphql( - `query ArchivedRecordingsForTarget($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + `query ArchivedRecordingsForTarget($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { archivedRecordings { data { @@ -210,7 +210,7 @@ export const BulkEditLabels: React.FC = ({ } } }`, - { connectUrl: target.connectUrl }, + { id: target.id! }, ), ), map((v) => v.data.targetNodes[0].target.archivedRecordings.data as ArchivedRecording[]), diff --git a/src/app/Recordings/ArchivedRecordingsTable.tsx b/src/app/Recordings/ArchivedRecordingsTable.tsx index ca08d6e1a..cbf240caa 100644 --- a/src/app/Recordings/ArchivedRecordingsTable.tsx +++ b/src/app/Recordings/ArchivedRecordingsTable.tsx @@ -187,12 +187,12 @@ export const ArchivedRecordingsTable: React.FC = ( ); const queryTargetRecordings = React.useCallback( - (connectUrl: string) => { + (targetId: number) => { /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ return context.api.graphql( ` - query ArchivedRecordingsForTarget($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + query ArchivedRecordingsForTarget($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { archivedRecordings { data { @@ -211,7 +211,7 @@ export const ArchivedRecordingsTable: React.FC = ( } } }`, - { connectUrl }, + { id: targetId }, ); }, [context.api], @@ -259,7 +259,7 @@ export const ArchivedRecordingsTable: React.FC = ( .pipe( filter((target) => !!target), first(), - concatMap((target: Target) => queryTargetRecordings(target.connectUrl)), + concatMap((target: Target) => queryTargetRecordings(target.id!)), map((v) => v.data.targetNodes[0].target.archivedRecordings.data as ArchivedRecording[]), ) .subscribe({ diff --git a/src/app/Shared/Services/Api.service.tsx b/src/app/Shared/Services/Api.service.tsx index 886ad2725..255036e9b 100644 --- a/src/app/Shared/Services/Api.service.tsx +++ b/src/app/Shared/Services/Api.service.tsx @@ -945,8 +945,8 @@ export class ApiService { concatMap((target) => this.graphql( ` - query PostRecordingMetadata($connectUrl: String, $recordingName: String, $labels: [Entry_String_StringInput]) { - targetNodes(filter: { name: $connectUrl }) { + query PostRecordingMetadata($id: BigInteger!, $recordingName: String, $labels: [Entry_String_StringInput]) { + targetNodes(filter: { targetIds: [$id] }) { target { archivedRecordings(filter: { name: $recordingName }) { data { @@ -966,7 +966,7 @@ export class ApiService { } }`, { - connectUrl: target.connectUrl, + id: target.id!, recordingName, labels: labels.map((label) => ({ key: label.key, value: label.value })), }, @@ -1010,8 +1010,8 @@ export class ApiService { concatMap((target: Target) => this.graphql( ` - query PostActiveRecordingMetadata($connectUrl: String, $recordingName: String, $labels: [Entry_String_StringInput]) { - targetNodes(filter: { name: $connectUrl }) { + query PostActiveRecordingMetadata($id: BigInteger!, $recordingName: String, $labels: [Entry_String_StringInput]) { + targetNodes(filter: { targetIds: [$id] }) { target { activeRecordings(filter: { name: $recordingName }) { data { @@ -1031,7 +1031,7 @@ export class ApiService { } }`, { - connectUrl: target.connectUrl, + id: target.id!, recordingName, labels: labels.map((label) => ({ key: label.key, value: label.value })), }, @@ -1193,8 +1193,8 @@ export class ApiService { targetHasRecording(target: TargetStub, filter: ActiveRecordingsFilterInput = {}): Observable { return this.graphql( ` - query ActiveRecordingsForJFRMetrics($connectUrl: String, $recordingFilter: ActiveRecordingsFilterInput) { - targetNodes(filter: { name: $connectUrl }) { + query ActiveRecordingsForJFRMetrics($id: BigInteger!, $recordingFilter: ActiveRecordingsFilterInput) { + targetNodes(filter: { targetIds: [$id] }) { target { activeRecordings(filter: $recordingFilter) { aggregate { @@ -1205,7 +1205,7 @@ export class ApiService { } }`, { - connectUrl: target.connectUrl, + id: target.id!, recordingFilter: filter, }, true, @@ -1280,8 +1280,8 @@ export class ApiService { getTargetMBeanMetrics(target: TargetStub, queries: string[]): Observable { return this.graphql( ` - query MBeanMXMetricsForTarget($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + query MBeanMXMetricsForTarget($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { mbeanMetrics { ${queries.join('\n')} @@ -1289,7 +1289,7 @@ export class ApiService { } } }`, - { connectUrl: target.connectUrl }, + { id: target.id! }, ).pipe( map((resp) => { const nodes = resp.data.targetNodes; @@ -1305,8 +1305,8 @@ export class ApiService { getTargetArchivedRecordings(target: TargetStub): Observable { return this.graphql( ` - query ArchivedRecordingsForTarget($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + query ArchivedRecordingsForTarget($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { archivedRecordings { data { @@ -1326,7 +1326,7 @@ export class ApiService { } } }`, - { connectUrl: target.connectUrl }, + { id: target.id! }, true, true, ).pipe(map((v) => v.data.targetNodes[0].target.archivedRecordings.data as ArchivedRecording[])); diff --git a/src/app/Topology/Entity/EntityDetails.tsx b/src/app/Topology/Entity/EntityDetails.tsx index 01814c76e..600e7392c 100644 --- a/src/app/Topology/Entity/EntityDetails.tsx +++ b/src/app/Topology/Entity/EntityDetails.tsx @@ -247,7 +247,7 @@ export const TargetDetails: React.FC<{ onToggle={onToggle} isExpanded={isExpanded} > - + ); @@ -255,9 +255,9 @@ export const TargetDetails: React.FC<{ const MBeanDetails: React.FC<{ isExpanded: boolean; - connectUrl: string; + targetId: number; columnModifier?: React.ComponentProps['columnModifier']; -}> = ({ isExpanded, connectUrl, columnModifier }) => { +}> = ({ isExpanded, targetId, columnModifier }) => { const context = React.useContext(ServiceContext); const [dayjs, dateTimeFormat] = useDayjs(); const addSubscription = useSubscriptions(); @@ -269,8 +269,8 @@ const MBeanDetails: React.FC<{ context.api .graphql( ` - query MBeanMXMetricsForTarget($connectUrl: String) { - targetNodes(filter: { name: $connectUrl }) { + query MBeanMXMetricsForTarget($id: BigInteger!) { + targetNodes(filter: { targetIds: [$id] }) { target { mbeanMetrics { runtime { @@ -297,7 +297,7 @@ const MBeanDetails: React.FC<{ } } }`, - { connectUrl }, + { id: targetId }, ) .pipe( map((resp) => resp.data.targetNodes[0].target.mbeanMetrics || {}), @@ -306,7 +306,7 @@ const MBeanDetails: React.FC<{ .subscribe(setMbeanMetrics), ); } - }, [isExpanded, addSubscription, connectUrl, context.api, setMbeanMetrics]); + }, [isExpanded, addSubscription, targetId, context.api, setMbeanMetrics]); const _collapsedData = React.useMemo((): DescriptionConfig[] => { return [