Repository navigation
feat: add export to excel functionality in reviewers and assignments tab in fap page - #1839
Bhaswati1148 wants to merge 30 commits into
Conversation
…ffice-core into 1574-export-fap-reviewers-review
…ffice-core into 1574-export-fap-reviewers-review
| .andWhere('call_id', callId); | ||
| .where('fap_id', fapId); | ||
|
|
||
| if (callId != 0) { |
There was a problem hiding this comment.
Is there a legitimate case where callId is 0?
There was a problem hiding this comment.
The callId is set to 0 when no calls are selected in the frontend.
There was a problem hiding this comment.
Could add a commment?
|
|
||
| cy.get('[data-cy="submit"]').click(); | ||
|
|
||
| cy.notification({ |
There was a problem hiding this comment.
What's the motivation behind removing this?
There was a problem hiding this comment.
I removed the notification assertion because the success notification appears and disappears very quickly, and I couldn't find a reliable way for Cypress to get hold of it before it disappeared. This was making the test unreliable. The assignment itself is still verified by checking that the proposal appears in the FAP assignments table, so the test continues to validate the operation successfully.
| return; | ||
| } | ||
| const reviewerProposalMap = new Map<number, number[]>(); | ||
| // const reviewerIds = rowData.map((reviewer) => reviewer.user.userId); |
There was a problem hiding this comment.
Can these commented out lines please be removed?
| }); | ||
| const reviewerProposals = Object.fromEntries(reviewerProposalMap); | ||
| reviewerProposalMap.forEach((key, value) => { | ||
| console.log('reviewerid ' + key + `proposals ` + value); |
There was a problem hiding this comment.
This logging can be removed now, I reckon.
mutambaraf
left a comment
There was a problem hiding this comment.
LGTM apart form just a few comments
| const userWithRole = { | ||
| ...res.locals.agent, | ||
| }; |
There was a problem hiding this comment.
We may need to validate we are getting all the information we need from this object.
There was a problem hiding this comment.
Id is the information we need from userWithRole object which will be used further in the process. The middleware effectively validates the user’s id, it reads req.user.user.id, looks up that user with getAgent(id), and returns an unauthorized response if no user is found. It then puts the resulting user data into res.locals.agent. So I believe a second id check in the XLSX handler would usually be redundant.
| const reviewerProposalsParam = req.query.reviewerProposals; | ||
|
|
||
| if (typeof reviewerProposalsParam !== 'string') { | ||
| throw new Error('reviewerProposals is required'); |
There was a problem hiding this comment.
We can say Proposals reviewer is required
mutambaraf
left a comment
There was a problem hiding this comment.
LGTM apart from the failing tests
| dateAssigned: formatDate(assignment.dateAssigned), | ||
| rank: assignment.rank ?? null, | ||
| grade: assignment.grade, | ||
| comment: stripHtml(assignment.comment ?? '-'), |
There was a problem hiding this comment.
We could be more clear about what comment this is. There are loads of different types of comments on proposals, which one?
There was a problem hiding this comment.
We could be more clear about what comment this is. There are loads of different types of comments on proposals, which one?
The Excel export feature is being added to the Review and Assignments tab on the FAP page. This tab displays reviewers and their reviews of proposals assigned to them, as well as reviews submitted by other reviewers. Therefore, the comments included in the Excel export refer specifically to the FAP reviewers’ comments on those proposals.
There was a problem hiding this comment.
Thus "FAP review comment" column heading?
|
Are we planning to support importing this in the future? |
…ffice-core into 1574-export-fap-reviewers-review
… this branch, so manually adding them
There are no plans to support importing this at the moment. |
| "luxon": "^3.4.4", | ||
| "pdf-parse": "^1.1.1", | ||
| "typescript": "~5.3.3", | ||
| "typescript": "^5.3.3", |
There was a problem hiding this comment.
From memory typescript doesn't actually follow semantic versioning. So when you put this ^ it allows the minor version to get automatically bumped. Which could potentially break UOS when someone releases to production. It seems like we shouldn't update any dependencies, maybe an accident while developing?
There was a problem hiding this comment.
also isn't typescript in dev dependencies now? Maybe this is a git branch conflict?
| comment, | ||
| status, | ||
| }: ReviewRowInput): Array<string | number> => [ | ||
| proposalId ?? '-', |
There was a problem hiding this comment.
The convention in the rest of the export xlsx is to use instead of - for this purpose. It would be good to be consistent.
|
|
||
| const rows = rankedRows | ||
| .sort((a, b) => { | ||
| if (a.rank === null || b.rank === null) { |
There was a problem hiding this comment.
If instead of using === you used == to check vs null then your code would also work for undefined
There was a problem hiding this comment.
Because currently your code puts null at the bottom, but undefined at the top which probably isn't desired
| return a.grade === null ? 1 : -1; | ||
| } | ||
| } else if (a.grade !== b.grade) { | ||
| return b.grade - a.grade; |
There was a problem hiding this comment.
Might be worth adding a comment that we are sorting from rank smallest to biggest, and grade biggest to smallest. Just to avoid confustion
|
|
||
| break; | ||
| } | ||
| case Event.PROPOSAL_DATA_ACCESS_INVITE_ACCEPTED: { |
There was a problem hiding this comment.
Why are you deleting this event?
There was a problem hiding this comment.
It seems that something went wrong while updating my branch with develop. I will revert back the changes that are not related to my changes.
| break; | ||
| default: { | ||
| let changedObjectId: number; | ||
| if (typeof (event as any)[event.key]?.primaryKey === 'number') { |
There was a problem hiding this comment.
Why are you changing this?
| const userRole = req.user.currentRole; | ||
|
|
||
| callFactoryService( | ||
| DownloadType.XLSX, |
There was a problem hiding this comment.
I just want to add that:
DownloadType.XLSX,
XLSXType.MANAGEMENT_DECISION,
seems to work perfectly fine.
The factory doesn't seem to need us to add a bespoke one for each download type.



Description
This PR adds the export to excel functionality in reviewers and assignments tab in fap page. The export creates multiple sheets if multiple users(reviewers) are selected.
The exported excel will have the columns : Proposal ID, Proposal title, Instrument, Date assigned, Rank, Grade, Comment, Status
Motivation and Context
This functionality has been added to allow the FAP Secretary in STFC to export reviewer reviews to Excel.
How Has This Been Tested
An E2E test has been added to verify the export functionality when the download button is clicked and to validate the contents of the exported Excel file.
Fixes
Closes UserOfficeProject/issue-tracker#1574
Changes
Depends on
Tests included/Docs Updated?