Skip to content

Commit

Permalink
GAP-2230: frontend times out when requesting many submissions (#90)
Browse files Browse the repository at this point in the history
* GAP-2230: Removing await so it calls the backend to start sending messages to SQS and doesnt wait for its response

* GAP-2230: Fixing synk issue

* GAP-2230: Fixing synk issue

* GAP-2230: Fixing synk issue

* GAP-2230: Fixing synk issue

* Cache dependencies on failure

* GAP-2230: Testing pipeline change

* Update feature.yml

* Update feature.yml

* GAP-2230: Fixing snyk issue

* GAP-2230: Only saving cache if there was no hit

* GAP-2230: Fixing pipeline if condition

* GAP-2230: Fixing unit tests
  • Loading branch information
dominicwest authored Oct 11, 2023
1 parent 431bf33 commit f7fcbb6
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 108 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
id: yarn-cache-dir-path

- name: Cache dependencies
uses: actions/cache@v2
- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: yarn-cache
with:
path: |
Expand All @@ -61,6 +61,16 @@ jobs:
run: |
yarn install --immutable
- name: Save cached dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Snyk setup
uses: snyk/actions/node@master
env:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"trim": "^0.0.3",
"trim-newlines": "^3.0.0",
"glob-parent": "^6.0.1",
"postcss": "8.4.14"
"postcss": "8.4.14",
"semver": "^7.5.2",
"word-wrap": "^1.2.4"
},
"packageManager": "[email protected]"
}
16 changes: 11 additions & 5 deletions packages/admin/.snyk
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ ignore:
created: 2023-06-21T14:47:46.321Z

SNYK-JS-WORDWRAP-3149973:
- '*':
reason: >-
Dev dependency - no upgrade currently available
expires: 2023-09-30T14:10:46.319Z
created: 2023-07-21T14:10:46.321Z
- '*':
reason: >-
Dev dependency - no upgrade currently available
expires: 2023-09-30T14:10:46.319Z
created: 2023-07-21T14:10:46.321Z

SNYK-JS-ADOBECSSTOOLS-5871286:
- '*':
reason: >-
Dev dependency - no upgrade currently available
expires: 2023-09-30T14:10:46.319Z
created: 2023-09-05T14:10:46.321Z
SNYK-JS-POSTCSS-5926692:
- '*':
reason: >-
Dev dependency - upgrade requires migration to next 13
expires: 2023-10-09T14:10:46.319Z
created: 2023-12-09T14:10:46.321Z
patch: {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ import {
} from '../../../services/SubmissionsService';
import { getLoggedInUsersDetails } from '../../../services/UserService';
import UserDetails from '../../../types/UserDetails';
import callServiceMethod from '../../../utils/callServiceMethod';
import {
generateErrorPageParams,
generateErrorPageRedirect,
} from '../../../utils/serviceErrorHelpers';
import { generateErrorPageRedirect } from '../../../utils/serviceErrorHelpers';
import { getSessionIdFromCookies } from '../../../utils/session';

export const getServerSideProps: GetServerSideProps = async ({
req,
res,
query,
resolvedUrl,
}) => {
Expand All @@ -41,11 +36,6 @@ export const getServerSideProps: GetServerSideProps = async ({
created: '',
};

const errorPageParams = generateErrorPageParams(
'Something went wrong while trying to export submissions.',
`/scheme/${schemeId}`
);

const errorPageRedirect = generateErrorPageRedirect(
'Something went wrong while trying to export submissions.',
req.headers.referer ? req.headers.referer : '/dashboard',
Expand Down Expand Up @@ -83,16 +73,13 @@ export const getServerSideProps: GetServerSideProps = async ({
}

if (exportStatus == ExportStatusEnum.NOT_STARTED) {
const response = await callServiceMethod(
req,
res,
() => requestSubmissionsExport(sessionCookie, applicationId),
`/scheme/${schemeId}/download-submissions`, // after export is triggered, redirect to same page
errorPageParams
);
if ('redirect' in response) {
return response;
}
requestSubmissionsExport(sessionCookie, applicationId);
return {
redirect: {
destination: `/scheme/${schemeId}/download-submissions`,
permanent: false,
},
};
}

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ import {
getApplicationExportStatus,
requestSubmissionsExport,
} from '../../../services/SubmissionsService';
import callServiceMethod from '../../../utils/callServiceMethod';

jest.mock('next/config', () => () => {
return {
serverRuntimeConfig: {
backendHost: 'http://localhost:8080',
},
publicRuntimeConfig: {
SUB_PATH: '/apply',
APPLICANT_DOMAIN: 'http://localhost:8080',
},
};
});

jest.mock('../../../services/SchemeService');
jest.mock('../../../services/ApplicationService');
Expand All @@ -40,8 +27,7 @@ const mockedGetLoggedInUsersDetails = getLoggedInUsersDetails as jest.Mock;

const mockedGetApplicationExportStatus =
getApplicationExportStatus as jest.Mock;

const mockedCallServiceMethod = callServiceMethod as jest.Mock;
const mockedRequestSubmissionsExport = requestSubmissionsExport as jest.Mock;

const customProps = {
backButtonHref: '/back',
Expand Down Expand Up @@ -227,17 +213,22 @@ describe('Download submissions page', () => {
);
});

it('Should return an empty user email when export is not in progress', async () => {
it('Should redirect to self when NOT_STARTED', async () => {
mockedGetApplicationExportStatus.mockResolvedValue(
ExportStatusEnum.NOT_STARTED
);
mockedCallServiceMethod.mockResolvedValue({});
mockedRequestSubmissionsExport.mockResolvedValue({});

const response = (await getServerSideProps(
getContext()
)) as NextGetServerSidePropsResponse;

expect(response.props.emailAddress).toStrictEqual('');
expect(response).toStrictEqual({
redirect: {
permanent: false,
destination: '/scheme/testSchemeId/download-submissions',
},
});
});

it.todo('Placeholder for checking if the export is in progress');
Expand All @@ -259,17 +250,16 @@ describe('Download submissions page', () => {
mockedGetApplicationExportStatus.mockResolvedValue(
ExportStatusEnum.NOT_STARTED
);
mockedCallServiceMethod.mockResolvedValue({});

await getServerSideProps(getPostContext());

expect(mockedCallServiceMethod).toBeCalled();
expect(mockedRequestSubmissionsExport).toBeCalledWith('', 1);
});

it('requestSubmissionsExport is not triggered if exportStatus is PROCESSING', async () => {
await getServerSideProps(getPostContext());

expect(mockedCallServiceMethod).not.toBeCalled();
expect(mockedRequestSubmissionsExport).not.toBeCalled();
});

it('Should return a user email if export is in progress', async () => {
Expand Down
16 changes: 11 additions & 5 deletions packages/applicant/.snyk
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ ignore:
created: 2023-06-21T14:47:46.321Z

SNYK-JS-WORDWRAP-3149973:
- '*':
reason: >-
Dev dependency - no upgrade currently available
expires: 2023-09-30T14:10:46.319Z
created: 2023-07-21T14:10:46.321Z
- '*':
reason: >-
Dev dependency - no upgrade currently available
expires: 2023-09-30T14:10:46.319Z
created: 2023-07-21T14:10:46.321Z

SNYK-JS-ADOBECSSTOOLS-5871286:
- '*':
reason: >-
Dev dependency - no upgrade currently available
expires: 2023-09-30T14:10:46.319Z
created: 2023-09-05T14:10:46.321Z
SNYK-JS-POSTCSS-5926692:
- '*':
reason: >-
Dev dependency - upgrade requires migration to next 13
expires: 2023-10-09T14:10:46.319Z
created: 2023-12-09T14:10:46.321Z
patch: {}
61 changes: 8 additions & 53 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16363,59 +16363,14 @@ __metadata:
languageName: node
linkType: hard

"semver@npm:2 || 3 || 4 || 5, semver@npm:^5.6.0":
version: 5.7.1
resolution: "semver@npm:5.7.1"
bin:
semver: ./bin/semver
checksum: 57fd0acfd0bac382ee87cd52cd0aaa5af086a7dc8d60379dfe65fea491fb2489b6016400813930ecd61fd0952dae75c115287a1b16c234b1550887117744dfaf
languageName: node
linkType: hard

"semver@npm:4.3.2":
version: 4.3.2
resolution: "semver@npm:4.3.2"
bin:
semver: ./bin/semver
checksum: a0bc4015f01c1843a4f270b0a8e668bbc99e2847d239ae9103c7eb54ab6b5c426d8e857c8796025fefeb131984825da977b0c2bcfbb2179ac22dbb018f91acfd
languageName: node
linkType: hard

"semver@npm:^6.0.0, semver@npm:^6.1.1, semver@npm:^6.1.2, semver@npm:^6.3.0":
version: 6.3.0
resolution: "semver@npm:6.3.0"
bin:
semver: ./bin/semver.js
checksum: 1b26ecf6db9e8292dd90df4e781d91875c0dcc1b1909e70f5d12959a23c7eebb8f01ea581c00783bbee72ceeaad9505797c381756326073850dc36ed284b21b9
languageName: node
linkType: hard

"semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8":
version: 7.5.1
resolution: "semver@npm:7.5.1"
"semver@npm:^7.5.2":
version: 7.5.4
resolution: "semver@npm:7.5.4"
dependencies:
lru-cache: ^6.0.0
bin:
semver: bin/semver.js
checksum: d16dbedad53c65b086f79524b9ef766bf38670b2395bdad5c957f824dcc566b624988013564f4812bcace3f9d405355c3635e2007396a39d1bffc71cfec4a2fc
languageName: node
linkType: hard

"semver@npm:~5.3.0":
version: 5.3.0
resolution: "semver@npm:5.3.0"
bin:
semver: ./bin/semver
checksum: 2717b14299c76a4b35aec0aafebca22a3644da2942d2a4095f26e36d77a9bbe17a9a3a5199795f83edd26323d5c22024a2d9d373a038dec4e023156fa166d314
languageName: node
linkType: hard

"semver@npm:~7.0.0":
version: 7.0.0
resolution: "semver@npm:7.0.0"
bin:
semver: bin/semver.js
checksum: 272c11bf8d083274ef79fe40a81c55c184dff84dd58e3c325299d0927ba48cece1f020793d138382b85f89bab5002a35a5ba59a3a68a7eebbb597eb733838778
checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3
languageName: node
linkType: hard

Expand Down Expand Up @@ -18344,10 +18299,10 @@ __metadata:
languageName: node
linkType: hard

"word-wrap@npm:^1.2.3, word-wrap@npm:~1.2.3":
version: 1.2.3
resolution: "word-wrap@npm:1.2.3"
checksum: 30b48f91fcf12106ed3186ae4fa86a6a1842416df425be7b60485de14bec665a54a68e4b5156647dec3a70f25e84d270ca8bc8cd23182ed095f5c7206a938c1f
"word-wrap@npm:^1.2.4":
version: 1.2.5
resolution: "word-wrap@npm:1.2.5"
checksum: f93ba3586fc181f94afdaff3a6fef27920b4b6d9eaefed0f428f8e07adea2a7f54a5f2830ce59406c8416f033f86902b91eb824072354645eea687dff3691ccb
languageName: node
linkType: hard

Expand Down

0 comments on commit f7fcbb6

Please sign in to comment.