Skip to content

Conversation

@mwejuli-ch
Copy link
Contributor

JIRA link

https://companieshouse.atlassian.net/browse/ROE-2559

Change description

  • Saves sold-land-filter option to the API
  • Refactors getApplicationData method to fetch data from API
  • Refactors all methods/objects making calls to promisified functions to use async/ await

Work checklist

  • Tests added where applicable
  • UI changes meet accessibility criteria

@mwejuli-ch mwejuli-ch force-pushed the feat/roe-2559/save-sold-land-filter-option-to-database branch from 0ab0482 to 5c3d9a3 Compare July 9, 2024 07:32

if (!response.httpStatusCode || response.httpStatusCode >= 400) {
throw createAndLogErrorRequest(req, `'postTransaction' for company number '${companyNumber}' with name '${companyName}' returned HTTP status code ${response.httpStatusCode}`);
throw createAndLogErrorRequest(req, `'>>error:>>>>>>>>postTransaction' for company number '${companyNumber}' with name '${companyName}' returned HTTP status code ${response.httpStatusCode}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The >>error:>>>>>>>> text here and below will need to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will get rid of these. The new PR doesn't have them.

import { isActiveFeature } from "./feature.flag";
import { getOverseasEntity } from "../service/overseas.entities.service";

export const getApplicationData = async (session: Session | undefined, req?: Request): Promise<ApplicationData> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume at some point this function will no longer take a session as parameter? Retrieval will always be based on a transaction and submission id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. When we have an entirely REDIS-free journey, this method will need not have this parameter.

import { getOverseasEntity } from "../service/overseas.entities.service";

export const getApplicationData = async (session: Session | undefined, req?: Request): Promise<ApplicationData> => {
if (typeof req === "undefined" || !isActiveFeature(FEATURE_FLAG_ENABLE_REDIS_REMOVAL)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, perhaps in the future, when work is nearer complete, if the request is undefined I think this should be an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

const submissionId: string = req.params[ROUTE_PARAM_SUBMISSION_ID] ?? "";

if (transactionId === "" && submissionId === "") {
return {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine if Redis cache removal isn't switched on, but if it is, is this an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specifically for the landing page of the journey where we have no transactionID and no submissionID, so it shouldn't error but should return an empty object.

return {};
}

const appData = await getOverseasEntity(req, transactionId, submissionId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are tests around this changed functionality to follow later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these were to follow later, but the revised implementation means they will now be part of a future PR.

try {

logger.debugRequest(req, `POST ${config.SOLD_LAND_FILTER_PAGE}`);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't see any tests for this changed functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now in the new PR here.

if (hasSoldLand !== '0') {
nextPageUrl = config.CANNOT_USE_URL;
} else {
if (!appData[Transactionkey]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting this change in behaviour to be feature flagged but it's not. That might be ok, but we need to discuss. Relates to this comment on the API change:

https://github.com/companieshouse/overseas-entities-api/pull/404/files#r1673848116

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, it makes sense to put this behind the Redis feature flag as it's a fundamental change to the behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Feature flag added to new PR here.

@mwejuli-ch mwejuli-ch changed the title Feat/ROE-2559: Save sold-land-filter option to database [DRAFT-ONLY]: Feat/ROE-2559: Save sold-land-filter option to database Jul 16, 2024
@mwejuli-ch mwejuli-ch changed the title [DRAFT-ONLY]: Feat/ROE-2559: Save sold-land-filter option to database [DRAFT-ONLY]: Save sold-land-filter option to database Jul 29, 2024
@mwejuli-ch mwejuli-ch changed the title [DRAFT-ONLY]: Save sold-land-filter option to database [DRAFT][FOR-REFERENCE-ONLY]: Save sold-land-filter option to database Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants