Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphql): query target nodes by targets' IDs rather than connectUrls #1245

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/Archives/AllTargetsArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ export const AllTargetsArchivedRecordingsTable: React.FC<AllTargetsArchivedRecor
addSubscription(
context.api
.graphql<any>(
`query ArchiveCountForTarget($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
`query ArchiveCountForTarget($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
archivedRecordings {
data {
Expand All @@ -248,7 +248,7 @@ export const AllTargetsArchivedRecordingsTable: React.FC<AllTargetsArchivedRecor
}
}
}`,
{ connectUrl: target.connectUrl },
{ id: target.id! },
)
.subscribe((v) => {
setArchivesForTargets((old) => {
Expand Down
26 changes: 13 additions & 13 deletions src/app/Dashboard/AutomatedAnalysis/AutomatedAnalysisCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
// 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<any>(
`
query ActiveRecordingsForAutomatedAnalysis($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
query ActiveRecordingsForAutomatedAnalysis($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
activeRecordings(filter: {
name: "${automatedAnalysisRecordingName}",
Expand All @@ -200,18 +200,18 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
}
}
}`,
{ 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<any>(
`query ArchivedRecordingsForAutomatedAnalysis($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
`query ArchivedRecordingsForAutomatedAnalysis($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
archivedRecordings {
data {
Expand All @@ -231,7 +231,7 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
}
}
}`,
{ connectUrl },
{ id: targetId },
);
},
[context.api],
Expand Down Expand Up @@ -300,8 +300,8 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>

// 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);
Expand All @@ -310,7 +310,7 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
setIsLoading(false);
} else {
addSubscription(
queryArchivedRecordings(connectUrl)
queryArchivedRecordings(target.id!)
.pipe(
first(),
map((v) => v.data.targetNodes[0].target.archivedRecordings.data as ArchivedRecording[]),
Expand Down Expand Up @@ -355,7 +355,7 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
)
.subscribe((target: Target) => {
addSubscription(
queryActiveRecordings(target.connectUrl)
queryActiveRecordings(target.id!)
.pipe(
first(),
tap((resp) => {
Expand Down Expand Up @@ -395,7 +395,7 @@ export const AutomatedAnalysisCard: DashboardCardFC<AutomatedAnalysisCardProps>
if (isAuthFail(err.message)) {
handleStateErrors(authFailMessage);
} else {
handleEmptyRecordings(target.connectUrl);
handleEmptyRecordings(target);
}
},
}),
Expand Down
6 changes: 3 additions & 3 deletions src/app/RecordingMetadata/BulkEditLabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ export const BulkEditLabels: React.FC<BulkEditLabelsProps> = ({
filter((target) => !!target),
concatMap((target: Target) =>
context.api.graphql<any>(
`query ArchivedRecordingsForTarget($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
`query ArchivedRecordingsForTarget($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
archivedRecordings {
data {
Expand All @@ -210,7 +210,7 @@ export const BulkEditLabels: React.FC<BulkEditLabelsProps> = ({
}
}
}`,
{ connectUrl: target.connectUrl },
{ id: target.id! },
),
),
map((v) => v.data.targetNodes[0].target.archivedRecordings.data as ArchivedRecording[]),
Expand Down
10 changes: 5 additions & 5 deletions src/app/Recordings/ArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ export const ArchivedRecordingsTable: React.FC<ArchivedRecordingsTableProps> = (
);

const queryTargetRecordings = React.useCallback(
(connectUrl: string) => {
(targetId: number) => {
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
return context.api.graphql<any>(
`
query ArchivedRecordingsForTarget($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
query ArchivedRecordingsForTarget($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
archivedRecordings {
data {
Expand All @@ -211,7 +211,7 @@ export const ArchivedRecordingsTable: React.FC<ArchivedRecordingsTableProps> = (
}
}
}`,
{ connectUrl },
{ id: targetId },
);
},
[context.api],
Expand Down Expand Up @@ -259,7 +259,7 @@ export const ArchivedRecordingsTable: React.FC<ArchivedRecordingsTableProps> = (
.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({
Expand Down
30 changes: 15 additions & 15 deletions src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,8 @@ export class ApiService {
concatMap((target) =>
this.graphql<any>(
`
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 {
Expand All @@ -966,7 +966,7 @@ export class ApiService {
}
}`,
{
connectUrl: target.connectUrl,
id: target.id!,
recordingName,
labels: labels.map((label) => ({ key: label.key, value: label.value })),
},
Expand Down Expand Up @@ -1010,8 +1010,8 @@ export class ApiService {
concatMap((target: Target) =>
this.graphql<any>(
`
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 {
Expand All @@ -1031,7 +1031,7 @@ export class ApiService {
}
}`,
{
connectUrl: target.connectUrl,
id: target.id!,
recordingName,
labels: labels.map((label) => ({ key: label.key, value: label.value })),
},
Expand Down Expand Up @@ -1193,8 +1193,8 @@ export class ApiService {
targetHasRecording(target: TargetStub, filter: ActiveRecordingsFilterInput = {}): Observable<boolean> {
return this.graphql<RecordingCountResponse>(
`
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 {
Expand All @@ -1205,7 +1205,7 @@ export class ApiService {
}
}`,
{
connectUrl: target.connectUrl,
id: target.id!,
recordingFilter: filter,
},
true,
Expand Down Expand Up @@ -1280,16 +1280,16 @@ export class ApiService {
getTargetMBeanMetrics(target: TargetStub, queries: string[]): Observable<MBeanMetrics> {
return this.graphql<MBeanMetricsResponse>(
`
query MBeanMXMetricsForTarget($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
query MBeanMXMetricsForTarget($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
mbeanMetrics {
${queries.join('\n')}
}
}
}
}`,
{ connectUrl: target.connectUrl },
{ id: target.id! },
).pipe(
map((resp) => {
const nodes = resp.data.targetNodes;
Expand All @@ -1305,8 +1305,8 @@ export class ApiService {
getTargetArchivedRecordings(target: TargetStub): Observable<ArchivedRecording[]> {
return this.graphql<any>(
`
query ArchivedRecordingsForTarget($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
query ArchivedRecordingsForTarget($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
archivedRecordings {
data {
Expand All @@ -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[]));
Expand Down
14 changes: 7 additions & 7 deletions src/app/Topology/Entity/EntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,17 @@ export const TargetDetails: React.FC<{
onToggle={onToggle}
isExpanded={isExpanded}
>
<MBeanDetails isExpanded={isExpanded} connectUrl={serviceRef.connectUrl} columnModifier={columnModifier} />
<MBeanDetails isExpanded={isExpanded} targetId={serviceRef.id!} columnModifier={columnModifier} />
</ExpandableSection>
</>
);
};

const MBeanDetails: React.FC<{
isExpanded: boolean;
connectUrl: string;
targetId: number;
columnModifier?: React.ComponentProps<typeof DescriptionList>['columnModifier'];
}> = ({ isExpanded, connectUrl, columnModifier }) => {
}> = ({ isExpanded, targetId, columnModifier }) => {
const context = React.useContext(ServiceContext);
const [dayjs, dateTimeFormat] = useDayjs();
const addSubscription = useSubscriptions();
Expand All @@ -269,8 +269,8 @@ const MBeanDetails: React.FC<{
context.api
.graphql<MBeanMetricsResponse>(
`
query MBeanMXMetricsForTarget($connectUrl: String) {
targetNodes(filter: { name: $connectUrl }) {
query MBeanMXMetricsForTarget($id: BigInteger!) {
targetNodes(filter: { targetIds: [$id] }) {
target {
mbeanMetrics {
runtime {
Expand All @@ -297,7 +297,7 @@ const MBeanDetails: React.FC<{
}
}
}`,
{ connectUrl },
{ id: targetId },
)
.pipe(
map((resp) => resp.data.targetNodes[0].target.mbeanMetrics || {}),
Expand All @@ -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 [
Expand Down
Loading