Skip to content

Commit

Permalink
UIDATIMP-1562 - Job Profile view displaying multiple links (#1493)
Browse files Browse the repository at this point in the history
* set query for Job Profile View to pull only child jobs when file splitting active.

* add tests for utility function

* fix job profile tests

* test undefined case for jobs URL utility function

* Update src/settings/JobProfiles/tests/ViewJobProfile.test.js

Co-authored-by: Mariia Aloshyna <55138456+mariia-aloshyna@users.noreply.github.com>

---------

Co-authored-by: Mariia Aloshyna <55138456+mariia-aloshyna@users.noreply.github.com>
  • Loading branch information
JohnC-80 and mariia-aloshyna authored Nov 2, 2023
1 parent 075b305 commit 213b46f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* The '[number of records] - records found' subtitle is displayed after clicking on the textLink error counter (UIDATIMP-1549)
* Display loading spinners while running jobs and job log displays are loading. (UIDATIMP-1557)
* Totals inaccurate on running composite job cards. Removed the 'failed jobs' display in those items and included erroneous jobs in the calculation of 'processed' job parts. (UIDATIMP-1563)
* Job profiles view - Jobs using this profile displaying multiple entries for single-part jobs. (UIDATIMP-1562)

## [7.0.1](https://github.com/folio-org/ui-data-import/tree/v7.0.1) (2023-10-27)

Expand Down
30 changes: 28 additions & 2 deletions src/settings/JobProfiles/ViewJobProfile/ViewJobProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import {
} from '../../../utils';

import RunJobModal from './RunJobModal';
import { requestConfiguration } from '../../../utils/multipartUpload';

import sharedCss from '../../../shared.css';

Expand All @@ -79,6 +80,18 @@ const {
ERROR,
} = FILE_STATUSES;

export function getAssociatedJobsURL(resources, splittingURL, nonSplitting) {
const { splitStatus } = resources;
if (!splitStatus?.isPending) {
if (splitStatus?.records[0]?.splitStatus) {
return splittingURL;
} else if (splitStatus?.records[0]?.splitStatus === false) {
return nonSplitting;
}
}
return undefined;
}

const jobPartsCellFormatter = record => (
<FormattedMessage
id="ui-data-import.logViewer.partOfTotal"
Expand Down Expand Up @@ -509,19 +522,32 @@ ViewJobProfileComponent.manifest = Object.freeze({
},
jobsUsingThisProfile: {
type: 'okapi',
path: (_q, _p) => {
path: (_q, _p, _l, _log, _props) => {
const { id } = _p;

return createUrlFromArray('metadata-provider/jobExecutions', [
const commonQueryParams = [
`statusAny=${COMMITTED}`,
`statusAny=${ERROR}`,
`profileIdAny=${id}`,
'limit=25',
'sortBy=completed_date,desc',
];

const nonSplittingJobsURL = createUrlFromArray('metadata-provider/jobExecutions', commonQueryParams);
const splittingJobsURL = createUrlFromArray('metadata-provider/jobExecutions', [...commonQueryParams,
'subordinationTypeNotAny=COMPOSITE_PARENT'
]);

return getAssociatedJobsURL(_props.resources, splittingJobsURL, nonSplittingJobsURL);
},
throwErrors: false,
},
splitStatus: {
type: 'okapi',
path: requestConfiguration,
shouldRefreshRemote: () => false,
throwErrors: false,
},
});
ViewJobProfileComponent.propTypes = {
stripes: stripesShape.isRequired,
Expand Down
25 changes: 24 additions & 1 deletion src/settings/JobProfiles/tests/ViewJobProfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import '../../../../test/jest/__mock__';

import { STATUS_CODES } from '../../../utils';

import { ViewJobProfile } from '../ViewJobProfile';
import { ViewJobProfile, getAssociatedJobsURL } from '../ViewJobProfile';
import { UploadingJobsContext } from '../../../components';

const uploadContext = (canUseObjectStorage) => (
Expand Down Expand Up @@ -367,4 +367,27 @@ describe('ViewJobProfile component', () => {
await waitFor(() => expect(queryByText('Are you sure you want to run this job?')).not.toBeInTheDocument());
});
});

describe('getAssociatedJobsURL', () => {
const splittingTrueResources = { splitStatus: { isPending: false, records: [{ splitStatus: true }] } };
const splittingFalseResources = { splitStatus: { isPending: false, records: [{ splitStatus: false }] } };
const undefinedResources = {};
const undefinedResourcesEmpty = { splitStatus: { isPending: false, records: [] } };

it('returns splitting URL when splitting is active', () => {
expect(getAssociatedJobsURL(splittingTrueResources, 'splittingTrueUrl', 'splittingFalseUrl')).toEqual('splittingTrueUrl');
});

it('returns non-splitting URL when splitting is inactive', () => {
expect(getAssociatedJobsURL(splittingFalseResources, 'splittingTrueUrl', 'splittingFalseUrl')).toEqual('splittingFalseUrl');
});

it('returns undefined when resource isn\'t ready', () => {
expect(getAssociatedJobsURL(undefinedResources, 'splittingTrueUrl', 'splittingFalseUrl')).toEqual(undefined);
});

it('returns undefined when resource returns empty', () => {
expect(getAssociatedJobsURL(undefinedResourcesEmpty, 'splittingTrueUrl', 'splittingFalseUrl')).toEqual(undefined);
});
});
});

0 comments on commit 213b46f

Please sign in to comment.