Follow+Notes: Expose ability to retrieve grant followers via Finder API #3399
Labels
collaboration
Grant Finder
Issues related to the Grant Finder
javascript
Pull requests that update Javascript code
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 users retrieve followers (within the same tenant/organization) of a particular grant.
Implementation Details
packages/server/src/lib/grantsCollaboration/followers.js
, update the exported interface with the following functions:getFollowersForGrant(knex, grantId, organizationId, { beforeFollow, limit = 50 })
grant_followers.created_at
in descending order (most recent first).knex
argument represents aknex
connection object, e.g. as implemented by the existingfollowGrant()
function.beforeFollow
argument, the main query should be limited to results wheregrant_followers.id
is less than that value.followersTotalCount
is the result of the count querypackages/server/src/lib/grantsCollaboration/index.js
, import/export thegetFollowersForGrant()
function exported frompackages/server/src/lib/grantsCollaboration/followers.js
packages/server/src/routes/grants.js
, define a newGET /:grantId/followers
API route handler as follows:getFollowersForGrant()
frompackages/server/src/lib/grantsCollaboration
with the grant ID and organization ID from the request.grantId
call argument should be provided by the request path parameters.organizationId
call argument should be the requesting user'stenant_id
attribute (i.e.req.session.user.tenant_id
).?paginateFrom
query parameter value is provided in the request, that value should be provided as thebeforeFollow
argument in the call togetFollowersForGrant()
.?limit
query parameter value is provided in the request, that value (as a parsed integer) should be provided as thelimit
argument in the call togetFollowersForGrant()
. Additionally, this value must pass the following validation checks (or else respond with a400 Bad Request
status):getFollowersForGrant()
, provides the function's return value as a JSON-serialized response.The text was updated successfully, but these errors were encountered: