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

remove the empty return for cssr #6000

Merged
merged 1 commit into from
Dec 4, 2023
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
25 changes: 16 additions & 9 deletions server/models/classes/establishment.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
this._pensionContribution = null;
this._sickPay = null;
this._recruitmentJourneyExistingUserBanner = false;
this._primaryAuthorityCssr = null;

// interim reasons for leaving - https://trello.com/c/vNHbfdms
this._reasonsForLeaving = null;
Expand Down Expand Up @@ -390,6 +391,9 @@
return this._recruitmentJourneyExistingUserBanner;
}

get primaryAuthorityCssr() {
return this._primaryAuthorityCssr;

Check warning on line 395 in server/models/classes/establishment.js

View check run for this annotation

Codecov / codecov/patch

server/models/classes/establishment.js#L395

Added line #L395 was not covered by tests
}
// used by save to initialise a new Establishment; returns true if having initialised this Establishment
_initialise() {
if (this._uid === null) {
Expand Down Expand Up @@ -607,6 +611,9 @@
if ('recruitmentJourneyExistingUserBanner' in document) {
this._recruitmentJourneyExistingUserBanner = document.recruitmentJourneyExistingUserBanner;
}
if ('primaryAuthorityCssr' in document) {
this._primaryAuthorityCssr = document.primaryAuthorityCssr;

Check warning on line 615 in server/models/classes/establishment.js

View check run for this annotation

Codecov / codecov/patch

server/models/classes/establishment.js#L615

Added line #L615 was not covered by tests
}
}

// allow for deep restoration of entities (associations - namely Worker here)
Expand Down Expand Up @@ -832,6 +839,7 @@
pensionContribution: this._pensionContribution,
careWorkersLeaveDaysPerYear: this._careWorkersLeaveDaysPerYear,
recruitmentJourneyExistingUserBanner: this._recruitmentJourneyExistingUserBanner,
primaryAuthorityCssr: this._primaryAuthorityCssr,
};

// need to create the Establishment record and the Establishment Audit event
Expand Down Expand Up @@ -1033,6 +1041,7 @@
pensionContribution: this._pensionContribution,
careWorkersLeaveDaysPerYear: this._careWorkersLeaveDaysPerYear,
recruitmentJourneyExistingUserBanner: bulkUploaded ? true : this._recruitmentJourneyExistingUserBanner,
primaryAuthorityCssr: this._primaryAuthorityCssr,
};

// Every time the establishment is saved, need to calculate
Expand Down Expand Up @@ -1293,7 +1302,6 @@
}

const fetchResults = await models.establishment.findOne(fetchQuery);
console.log({ fetchResults: fetchResults });
if (fetchResults && fetchResults.id && Number.isInteger(fetchResults.id)) {
// update self - don't use setters because they modify the change state
this._isNew = false;
Expand Down Expand Up @@ -1348,6 +1356,8 @@
this._pensionContribution = fetchResults.pensionContribution;
this._careWorkersLeaveDaysPerYear = fetchResults.careWorkersLeaveDaysPerYear;
this._careWorkersCashLoyaltyForFirstTwoYears = fetchResults.careWorkersCashLoyaltyForFirstTwoYears;

this._primaryAuthorityCssr = this.primaryAuthorityCssr;

Check warning on line 1360 in server/models/classes/establishment.js

View check run for this annotation

Codecov / codecov/patch

server/models/classes/establishment.js#L1360

Added line #L1360 was not covered by tests
// if history of the User is also required; attach the association
// and order in reverse chronological - note, order on id (not when)
// because ID is primay key and hence indexed
Expand Down Expand Up @@ -1517,16 +1527,13 @@

const cssrResults = await models.pcodedata.getLinkedCssrRecordsFromPostcode(this._postcode);

if (!cssrResults || cssrResults.length == 0) {
console.log('Could not retrieve cssr record');
return {};
if (cssrResults.length > 0) {
fetchResults.primaryAuthorityCssr = {

Check warning on line 1531 in server/models/classes/establishment.js

View check run for this annotation

Codecov / codecov/patch

server/models/classes/establishment.js#L1530-L1531

Added lines #L1530 - L1531 were not covered by tests
id: cssrResults[0].cssrRecord.id,
name: cssrResults[0].cssrRecord.name,
};
}

fetchResults.primaryAuthorityCssr = {
id: cssrResults[0].cssrRecord.id,
name: cssrResults[0].cssrRecord.name,
};

if (fetchResults.auditEvents) {
this._auditEvents = fetchResults.auditEvents;
}
Expand Down
8 changes: 0 additions & 8 deletions server/services/establishment/establishment.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ const addEstablishment = async (req, res) => {
// gets requested establishment
// optional parameter - "history" must equal "none" (default), "property", "timeline" or "full"
const getEstablishment = async (req, res) => {
console.log('getEstablishment request');
const establishmentId = req.params.id;

const showHistory =
Expand All @@ -198,12 +197,6 @@ const getEstablishment = async (req, res) => {
const showPropertyHistoryOnly = req.query.history === 'property';

const thisEstablishment = new Establishment.Establishment(req.username);
console.log({
thisEstablishment: thisEstablishment,
establishmentId: establishmentId,
showHistory: showHistory,
history: req.query.history,
});
try {
if (await thisEstablishment.restore(establishmentId, showHistory && req.query.history !== 'property')) {
// the property based framework for "other services" and "capacity services"
Expand Down Expand Up @@ -231,7 +224,6 @@ const getEstablishment = async (req, res) => {
}
if (!jsonResponse.isParent && jsonResponse.parentUid !== null) {
const parentEstablishmentName = await thisEstablishment.fetchParentDetails(jsonResponse.parentUid);
console.log({ parentEstablishmentName: parentEstablishmentName });
if (parentEstablishmentName) {
jsonResponse.parentName = parentEstablishmentName.parentName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export class WorkplaceInfoPanelComponent implements OnInit, OnDestroy {
event.preventDefault();

this.establishmentService.getEstablishment(this.workplace.uid).subscribe((data) => {
console.log({ workplaceDATA: data });
if (data.employerType == null) {
this.establishmentService.setEmployerTypeHasValue(false);
this.router.navigate(['/workplace', this.workplace.uid, 'type-of-employer']);
Expand Down