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

Follow+Notes: Add grant followers management to collaboration library #3203

Open
Tracked by #2960
TylerHendrickson opened this issue Jun 21, 2024 · 1 comment
Open
Tracked by #2960
Assignees
Labels
collaboration Grant Finder Issues related to the Grant Finder javascript Pull requests that update Javascript code

Comments

@TylerHendrickson
Copy link
Member

TylerHendrickson commented Jun 21, 2024

Subtask of [STORY]: Update 'Status' to 'Follow + Note' feature #2960

Blocked by

Blocks

Definition of Done

The library at packages/server/src/lib/grantsCollaboration provides new exported functions for adding, removing, and retrieving followers of grants.

Implementation Details

  • Create a knex migration that defines a new grant_followers table with the following schema:
    • Columns:
      • id: serial, not null, primary key
      • grant_id: text, not null, foreign key to grants.grant_id
      • user_id: int, not null, foreign key to users.id
      • created_at: timestamp with time zone, not null, default now()
    • Unique index idx_grant_id_user_id on columns (grant_id, user_id)
  • Add the following functions to the exported interface of the packages/server/src/lib/grantsCollaboration library:
    • followGrant(knex, grantId, userId) (void)
      • This function should insert a new row into the grant_followers table to record that the identified user is now following the identified grant.
      • The knex argument represents a knex connection object, e.g. as exported by packages/server/src/db/index.js.
      • Unique constraint violations that may occur upon insert (i.e. because the user is already following the grant) should be handled in such a way that any database transaction associated with the provided knex object may proceed. Therefore, this function should begin a new (sub-)transaction before insert, roll back the transaction on unique constraint violation, and commit the transaction following a successful insert.
    • unfollowGrant(knex, grantId, userId) (void)
      • This function should delete the row pertaining to the given user/grant combination from the grant_followers table.
    • Note that while these functions should be exported by the grantsCollaboration library, they should be defined in grantsCollaboration/followers.js and imported/exported in grantsCollaboration/index.js.
@ClaireValdivia
Copy link
Contributor

no front end changes to test, but general regression testing looked good on staging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collaboration Grant Finder Issues related to the Grant Finder javascript Pull requests that update Javascript code
Projects
Status: 🚢 Completed
Development

No branches or pull requests

3 participants