-
Notifications
You must be signed in to change notification settings - Fork 21
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
Follow+Notes: Retrieve note(s) for grant by a specific user via Finder API #3426
Comments
@TylerHendrickson The approach you suggested -
for creating getOrganizationNotesForGrantByUser function, we are not utilizing the organizationId parameter. I am currently following your steps but is this something we should revisit? |
Good spot! I think it would be best to keep the function getOrganizationNotesForGrantByUser(knex, grantId, organizationId, userId, { afterRevision, limit = 50 } = {}) {
return getCurrentNoteRevisions(knex, { grantId, organizationId, userId }, { afterRevision, limit });
} This will help ensure that results can always be limited to a particular organization. |
@TylerHendrickson Thanks, I will do this, it gives more flexibility in the future. |
Subtask of [STORY]: Update 'Status' to 'Follow + Note' feature #2960
Blocked by
N/A
Blocks
Definition of Done
A new API route exists that allows retrieval of the latest revision for each note pertaining to a specific user and grant.
Implementation Details
packages/server/src/lib/grantsCollaboration/notes.js
, update the exported interface with the following functions:getOrganizationNotesForGrantByUser(knex, organizationId, userId, grantId, { afterRevision, limit = 50 } = {})
grant_notes_revisions.created_at
in descending order (most recent first).getOrganizationNotesForGrant()
function togetCurrentNoteRevisions()
and update it's argument signature to(knex, { grantId, organizationId, userId } = {}, { afterRevision, limit = 50 } = {})
.getCurrentNotesRevisions()
function so that theWHERE
filters of the query pertaining togrant_notes.grant_id = :grantId
andgrant_notes.user_id = :userId
are conditional and only applied whengrantId
anduserId
are not null/undefined
. In other words, we want to make the behavior of limiting query results to those pertaining to a specific user and/or grant optional.getOrganizationNotesForGrantByUser()
function as a simple wrapper that callsgetCurrentNotesRevisions()
and returns the return value from that internal call, e.g.packages/server/src/lib/grantsCollaboration/notes.js
module.getOrganizationNotesForGrant(knex, grantId, organizationId, { afterRevision, limit = 50 } = {})
function (which implements the same original call signature) as another simple wrapper forgetCurrentNoteRevisions()
, e.g.packages/server/src/lib/grantsCollaboration/index.js
, import/export thegetOrganizationNotesForGrantByUser()
function exported frompackages/server/src/lib/grantsCollaboration/notes.js
packages/server/src/routes/grants.js
, define a newGET /:grantId/notes/user/:userId
API route handler as follows:getOrganizationNotesForGrantByUser()
frompackages/server/src/lib/grantsCollaboration
to retrieve a (paginated) result set of notes pertaining to the grant, organization, and user identified in the request.grantId
anduserId
call arguments togetOrganizationNotesForGrantByUser()
should all be derived from the corresponding request path parameter (req.params
) values.organizationId
call argument togetOrganizationNotesForGrantByUser()
should be thetenant_id
of the user provided by the request session (req.session.user.tenant_id
)?paginateFrom
query parameter value is provided in the request, that value should be provided as theafterRevision
argument in the call togetOrganizationNotesForGrantByUser()
.?limit
query parameter value is provided in the request, that value (as a parsed integer) should be provided as thelimit
argument in the call togetOrganizationNotesForGrantByUser()
. Additionally, this value must pass the following validation checks (or else respond with a400 Bad Request
status):getOrganizationNotesForGrantByUser()
, provides the function's return value as a JSON-serialized response.The text was updated successfully, but these errors were encountered: