-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat(DTFS2-7498): fetch amendments eligibility criteria from db #4155
base: main
Are you sure you want to change the base?
feat(DTFS2-7498): fetch amendments eligibility criteria from db #4155
Conversation
.find({ $and: [{ facilityType }, { isInDraft: { $eq: false } }] }) | ||
.sort({ version: -1 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this one of those magic mongodb things where it filters for a content within the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $elemMatch
does this if its not doing magic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice though!
.find({ $and: [{ facilityType }, { isInDraft: { $eq: false } }] }) | ||
.sort({ version: -1 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $elemMatch
does this if its not doing magic
.find({ $and: [{ facilityType }, { isInDraft: { $eq: false } }] }) | ||
.sort({ version: -1 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice though!
@@ -39,6 +41,12 @@ export class PortalFacilityAmendmentService { | |||
throw new InvalidAuditDetailsError(`Supplied auditDetails 'id' ${auditDetails.id.toString()} does not correspond to a valid user`); | |||
} | |||
|
|||
const { type: facilityType } = await findOneFacility(facilityId); | |||
|
|||
const { version, criteria } = await EligibilityCriteriaAmendmentsRepo.findLatestEligibilityCriteria(facilityType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think version
make sense at a glance - it probably should be eligibilityCriteriaVersion
or similar
}), | ||
), | ||
}) | ||
.optional(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this not be optional?
}), | ||
}, | ||
{ | ||
description: 'eligibility is missing id', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think these need updating to criteria
@@ -41,12 +41,18 @@ export const getEligibility = async (req: GetEligibilityRequest, res: Response) | |||
return res.redirect('/not-found'); | |||
} | |||
|
|||
// TODO 7765: Fetch criteria using GET endpoint from database and add to viewModel | |||
if (!amendment.eligibilityCriteria) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprised that this is optional
export type AmendmentsEligibilityCriterion = { | ||
id: number; | ||
text: string; | ||
textList?: string[]; | ||
answer: boolean | null; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this extend the db type - confused me a bit but happy to leave
const exception = new EligibilityCriteriaNotFoundError(); | ||
|
||
// Assert | ||
expect(exception.message).toEqual('Latest eligibility criteria not found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this always be latest
- think its fine to leave tbh
import { ApiError } from './api.error'; | ||
import { EligibilityCriteriaNotFoundError } from './eligibility-criteria-not-found.error'; | ||
|
||
describe('EligibilityCriteriaNotFoundError', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check the status of the error
isInDraft: boolean; | ||
createdAt: UnixTimestampMilliseconds; | ||
criteria: EligibilityCriterion[]; | ||
auditRecord?: AuditDatabaseRecord; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if we need auditRecords
- if these are inputted manually into the database then they wont be needed. If we're expecting them then Abhi should create it with type: none
Introduction ✏️
Include a summary of the changes and related feature(s) or issue(s).
Resolution ✔️
List all changes made to the codebase.
Miscellaneous ➕
List any additional fixes or improvements.