[Synthetics] Fix next / prev test navigation (#155624)

This commit is contained in:
Shahzad 2023-04-25 08:11:19 +02:00 committed by GitHub
parent 1ae38df15d
commit 4e4f408a34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 29 deletions

View file

@ -57,19 +57,23 @@ export const StepPageNavigation = ({ testRunPage }: { testRunPage?: boolean }) =
checkGroupId: data?.details?.next?.checkGroup,
});
if (testRunPage && data?.details?.previous?.checkGroup && data?.details?.next?.checkGroup) {
prevHref = getTestRunDetailLink({
basePath,
monitorId,
locationId: selectedLocation?.id,
checkGroup: data?.details?.previous?.checkGroup,
});
nextHref = getTestRunDetailLink({
basePath,
monitorId,
locationId: selectedLocation?.id,
checkGroup: data?.details?.next?.checkGroup,
});
if (testRunPage) {
if (data?.details?.previous?.checkGroup) {
prevHref = getTestRunDetailLink({
basePath,
monitorId,
locationId: selectedLocation?.id,
checkGroup: data?.details?.previous?.checkGroup,
});
}
if (data?.details?.next?.checkGroup) {
nextHref = getTestRunDetailLink({
basePath,
monitorId,
locationId: selectedLocation?.id,
checkGroup: data?.details?.next?.checkGroup,
});
}
}
if (!startedAt) {

View file

@ -64,6 +64,15 @@ export const getJourneyDetails: UMElasticsearchQueryFn<
body: {
query: {
bool: {
must_not: [
{
term: {
'monitor.check_group': {
value: journeySource.monitor.check_group,
},
},
},
],
filter: [
{
term: {
@ -93,6 +102,7 @@ export const getJourneyDetails: UMElasticsearchQueryFn<
...baseSiblingParams.body,
query: {
bool: {
must_not: baseSiblingParams.body.query.bool.must_not,
filter: [
...baseSiblingParams.body.query.bool.filter,
{
@ -114,6 +124,7 @@ export const getJourneyDetails: UMElasticsearchQueryFn<
...baseSiblingParams.body,
query: {
bool: {
must_not: baseSiblingParams.body.query.bool.must_not,
filter: [
...baseSiblingParams.body.query.bool.filter,
{
@ -151,20 +162,6 @@ export const getJourneyDetails: UMElasticsearchQueryFn<
({ _source: summarySource }) => summarySource.synthetics?.type === 'heartbeat/summary'
)?._source;
const previousInfo = previousJourney
? {
checkGroup: previousJourney._source.monitor.check_group,
timestamp: previousJourney._source['@timestamp'],
}
: undefined;
const nextInfo = nextJourney
? {
checkGroup: nextJourney._source.monitor.check_group,
timestamp: nextJourney._source['@timestamp'],
}
: undefined;
return {
timestamp: journeySource['@timestamp'],
journey: { ...journeySource, _id: foundJourney._id },
@ -175,10 +172,19 @@ export const getJourneyDetails: UMElasticsearchQueryFn<
},
}
: {}),
previous: previousInfo,
next: nextInfo,
previous: filterNextPrevJourney(journeySource.monitor.check_group, previousJourney?._source),
next: filterNextPrevJourney(journeySource.monitor.check_group, nextJourney?._source),
};
} else {
return null;
}
};
const filterNextPrevJourney = (checkGroup: string, pingSource: DocumentSource) => {
return pingSource && pingSource.monitor.check_group !== checkGroup
? {
checkGroup: pingSource.monitor.check_group,
timestamp: pingSource['@timestamp'],
}
: undefined;
};