diff --git a/src/bot/__tests__/getReviewInfo.test.ts b/src/bot/__tests__/getReviewInfo.test.ts index 467ab86d..690f9041 100644 --- a/src/bot/__tests__/getReviewInfo.test.ts +++ b/src/bot/__tests__/getReviewInfo.test.ts @@ -46,7 +46,6 @@ describe('getReviewInfo', () => { languages: ['Java'], requestedAt: new Date(1650504468906), dueBy: Deadline.END_OF_DAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 1, acceptedReviewers: [], diff --git a/src/bot/__tests__/requestReview.test.ts b/src/bot/__tests__/requestReview.test.ts index 4bae181c..0ff2d95e 100644 --- a/src/bot/__tests__/requestReview.test.ts +++ b/src/bot/__tests__/requestReview.test.ts @@ -5,7 +5,6 @@ import { ShortcutParam } from '@/slackTypes'; import { ActionId, Deadline, Interaction } from '@bot/enums'; import { requestReview } from '@bot/requestReview'; import { languageRepo } from '@repos/languageRepo'; -import { reviewTypesRepo } from '@repos/reviewTypesRepo'; import { App, SlackViewAction, UploadedFile, ViewStateValue } from '@slack/bolt'; import { buildMockCallbackParam, @@ -78,9 +77,6 @@ describe('requestReview', () => { describe('when no errors occur', () => { beforeEach(async () => { languageRepo.listAll = jest.fn().mockResolvedValueOnce(['Javascript', 'Go', 'Other']); - reviewTypesRepo.listAll = jest - .fn() - .mockResolvedValueOnce(['HackerRank', 'Moby Dick Project']); await requestReview.shortcut(param); }); @@ -107,34 +103,10 @@ describe('requestReview', () => { }); }); - it('should setup the first response block for the review type', () => { + it('should setup the first response block for the languages used', () => { const { mock } = param.client.views.open as jest.Mock; const blocks = mock.calls[0][0].view.blocks; expect(blocks[0]).toEqual({ - block_id: ActionId.REVIEW_TYPE, - type: 'input', - label: { - text: 'What type of submission needs reviewed?', - type: 'plain_text', - }, - element: { - type: 'static_select', - action_id: ActionId.REVIEW_TYPE, - options: [ - { text: { text: 'HackerRank', type: 'plain_text' }, value: 'HackerRank' }, - { - text: { text: 'Moby Dick Project', type: 'plain_text' }, - value: 'Moby Dick Project', - }, - ], - }, - }); - }); - - it('should setup the second response block for the languages used', () => { - const { mock } = param.client.views.open as jest.Mock; - const blocks = mock.calls[0][0].view.blocks; - expect(blocks[1]).toEqual({ block_id: ActionId.LANGUAGE_SELECTIONS, type: 'input', label: { @@ -153,10 +125,10 @@ describe('requestReview', () => { }); }); - it('should setup the third response block for when the reviews are needed by', () => { + it('should setup the second response block for when the reviews are needed by', () => { const { mock } = param.client.views.open as jest.Mock; const blocks = mock.calls[0][0].view.blocks; - expect(blocks[2]).toEqual({ + expect(blocks[1]).toEqual({ block_id: ActionId.REVIEW_DEADLINE, type: 'input', label: { @@ -178,10 +150,10 @@ describe('requestReview', () => { }); }); - it('should setup the forth response block for the number of reviewers necessary', () => { + it('should setup the third response block for the number of reviewers necessary', () => { const { mock } = param.client.views.open as jest.Mock; const blocks = mock.calls[0][0].view.blocks; - expect(blocks[3]).toEqual({ + expect(blocks[2]).toEqual({ block_id: ActionId.NUMBER_OF_REVIEWERS, type: 'input', label: { @@ -200,13 +172,13 @@ describe('requestReview', () => { it('should default the number of reviewers to 2, the number required for a new hire', () => { const { mock } = param.client.views.open as jest.Mock; const blocks = mock.calls[0][0].view.blocks; - expect(blocks[3].element.initial_value).toEqual('2'); + expect(blocks[2].element.initial_value).toEqual('2'); }); - it('should setup the sixth response block for the PDF file input', () => { + it('should setup the fifth response block for the PDF file input', () => { const { mock } = param.client.views.open as jest.Mock; const blocks = mock.calls[0][0].view.blocks; - expect(blocks[5]).toEqual({ + expect(blocks[4]).toEqual({ type: 'input', block_id: ActionId.PDF_IDENTIFIER, label: { @@ -222,19 +194,16 @@ describe('requestReview', () => { }); }); - it('should not setup the sixth response block for the PDF file input when HackParser is not enabled', async () => { + it('should not setup the fifth response block for the PDF file input when HackParser is not enabled', async () => { process.env.HACK_PARSER_BUCKET_NAME = ''; languageRepo.listAll = jest.fn().mockResolvedValueOnce(['Javascript', 'Go', 'Other']); - reviewTypesRepo.listAll = jest - .fn() - .mockResolvedValueOnce(['HackerRank', 'Moby Dick Project']); await requestReview.shortcut(param); const { mock } = param.client.views.open as jest.Mock; const blocks = mock.calls[1][0].view.blocks; - expect(blocks[5]).toBeUndefined(); + expect(blocks[4]).toBeUndefined(); }); }); @@ -265,7 +234,6 @@ describe('requestReview', () => { beforeEach(async () => { param.client.views.open = jest.fn().mockRejectedValueOnce('Dialog failed'); languageRepo.listAll = jest.fn().mockResolvedValueOnce([]); - reviewTypesRepo.listAll = jest.fn().mockResolvedValueOnce([]); await requestReview.shortcut(param); }); @@ -313,15 +281,6 @@ describe('requestReview', () => { }, }, }, - [ActionId.REVIEW_TYPE]: { - [ActionId.REVIEW_TYPE]: { - type: 'static_select', - selected_option: { - text: { type: 'plain_text', text: 'Moby Dick Project' }, - value: 'Moby Dick Project', - }, - }, - }, [ActionId.NUMBER_OF_REVIEWERS]: { [ActionId.NUMBER_OF_REVIEWERS]: { type: 'plain_text_input', @@ -400,7 +359,7 @@ describe('requestReview', () => { expect(param.client.chat.postMessage).toBeCalledWith({ channel: 'some-channel-id', text: ` - <@${param.body.user.id}> has requested 1 reviews for a Moby Dick Project done in the following languages: + <@${param.body.user.id}> has requested 1 reviews for a HackerRank done in the following languages: • Go • Javascript @@ -427,7 +386,6 @@ _Candidate Identifier: some-identifier_ languages: ['Go', 'Javascript'], requestedAt: expect.any(Date), dueBy: Deadline.MONDAY, - reviewType: 'Moby Dick Project', candidateIdentifier: 'some-identifier', reviewersNeededCount: '1', acceptedReviewers: [], diff --git a/src/bot/enums.ts b/src/bot/enums.ts index 6a4e8954..d81bed4c 100644 --- a/src/bot/enums.ts +++ b/src/bot/enums.ts @@ -21,7 +21,6 @@ export const enum ActionId { CANDIDATE_IDENTIFIER = 'candidate-identifier', REVIEWER_DM_ACCEPT = 'reviewer-dm-accept', REVIEWER_DM_DECLINE = 'reviewer-dm-deny', - REVIEW_TYPE = 'review-type', PDF_IDENTIFIER = 'pdf-identifier', } diff --git a/src/bot/requestReview.ts b/src/bot/requestReview.ts index 2054aff9..3ccedcd4 100644 --- a/src/bot/requestReview.ts +++ b/src/bot/requestReview.ts @@ -2,7 +2,6 @@ import { CallbackParam, ShortcutParam } from '@/slackTypes'; import { isViewSubmitActionParam } from '@/typeGuards'; import { activeReviewRepo } from '@repos/activeReviewsRepo'; import { languageRepo } from '@repos/languageRepo'; -import { reviewTypesRepo } from '@repos/reviewTypesRepo'; import { QueueService } from '@services'; import { App, Block, KnownBlock, PlainTextOption, View } from '@slack/bolt'; import { blockUtils } from '@utils/blocks'; @@ -28,21 +27,8 @@ export const requestReview = { app.view(Interaction.SUBMIT_REQUEST_REVIEW, this.callback.bind(this)); }, - dialog(languages: string[], reviewTypes: string[]): View { + dialog(languages: string[]): View { const blocks: (Block | KnownBlock)[] = [ - { - type: 'input', - block_id: ActionId.REVIEW_TYPE, - label: { - text: 'What type of submission needs reviewed?', - type: 'plain_text', - }, - element: { - type: 'static_select', - action_id: ActionId.REVIEW_TYPE, - options: buildReviewTypeOptions(reviewTypes), - }, - }, { type: 'input', block_id: ActionId.LANGUAGE_SELECTIONS, @@ -146,11 +132,10 @@ export const requestReview = { try { const languages = await languageRepo.listAll(); - const reviewTypes = await reviewTypesRepo.listAll(); await client.views.open({ trigger_id: shortcut.trigger_id, - view: this.dialog(languages, reviewTypes), + view: this.dialog(languages), }); // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { @@ -178,8 +163,6 @@ export const requestReview = { const deadline = blockUtils.getBlockValue(body, ActionId.REVIEW_DEADLINE); const numberOfReviewers = blockUtils.getBlockValue(body, ActionId.NUMBER_OF_REVIEWERS); const candidateIdentifier = blockUtils.getBlockValue(body, ActionId.CANDIDATE_IDENTIFIER); - const reviewType = blockUtils.getBlockValue(body, ActionId.REVIEW_TYPE).selected_option.text - .text; let pdfIdentifier = ''; // if HackParser is enabled AND the user uploaded a PDF file: download it from slack, and upload it to the HackParser S3 bucket @@ -225,7 +208,7 @@ export const requestReview = { compose( `${mention( user, - )} has requested ${numberOfReviewersValue} reviews for a ${reviewType} done in the following languages:`, + )} has requested ${numberOfReviewersValue} reviews for a HackerRank done in the following languages:`, ul(...languages), bold(`The review is needed by end of day ${deadlineDisplay}`), candidateIdentifierValue ? italic(`Candidate Identifier: ${candidateIdentifierValue}`) : '', @@ -263,7 +246,6 @@ export const requestReview = { { id: user.id }, languages, deadlineDisplay, - reviewType, ); const pendingReviewer: PendingReviewer = { userId: reviewer.id, @@ -279,7 +261,6 @@ export const requestReview = { languages, requestedAt: new Date(), dueBy: deadlineValue, - reviewType: reviewType, candidateIdentifier: candidateIdentifierValue, reviewersNeededCount: numberOfReviewersValue, acceptedReviewers: [], @@ -301,12 +282,6 @@ function buildDeadlineOptions(): PlainTextOption[] { ]; } -function buildReviewTypeOptions(reviewTypes: string[]): PlainTextOption[] { - return reviewTypes.map(reviewType => { - return { text: { text: reviewType, type: 'plain_text' }, value: reviewType }; - }); -} - function buildOption(deadline: Deadline): PlainTextOption { return { text: { text: DeadlineLabel.get(deadline) || '', type: 'plain_text' }, value: deadline }; } diff --git a/src/cron/__tests__/reviewProcessor.test.ts b/src/cron/__tests__/reviewProcessor.test.ts index de3c64c6..07ca76d1 100644 --- a/src/cron/__tests__/reviewProcessor.test.ts +++ b/src/cron/__tests__/reviewProcessor.test.ts @@ -14,7 +14,6 @@ function mockReview(pendingReviewers: PendingReviewer[]): ActiveReview { threadId: Math.random().toString(), acceptedReviewers: [], dueBy: Deadline.MONDAY, - reviewType: 'HackerRank', candidateIdentifier: '', languages: [], pendingReviewers, diff --git a/src/database/models/ActiveReview.ts b/src/database/models/ActiveReview.ts index cb65efbd..6874d701 100644 --- a/src/database/models/ActiveReview.ts +++ b/src/database/models/ActiveReview.ts @@ -6,7 +6,6 @@ export interface ActiveReview { languages: string[]; requestedAt: Date; dueBy: Deadline; - reviewType: string; candidateIdentifier: string; /** * The number of reviewers requested for this review. It should not change over the life of the diff --git a/src/database/repos/activeReviewsRepo.ts b/src/database/repos/activeReviewsRepo.ts index a5d7e660..16aa7f79 100644 --- a/src/database/repos/activeReviewsRepo.ts +++ b/src/database/repos/activeReviewsRepo.ts @@ -9,7 +9,6 @@ enum Column { LANGUAGES = 'languages', REQUESTED_AT = 'requestedAt', DUE_BY = 'dueBy', - REVIEW_TYPE = 'reviewType', CANDIDATE_IDENTIFIER = 'candidateIdentifier', REVIEWERS_NEEDED_COUNT = 'reviewersNeededCount', ACCEPTED_REVIEWERS = 'acceptedReviewers', @@ -33,7 +32,6 @@ function mapRowToActiveReview(row: GoogleSpreadsheetRow): ActiveReview { languages: row[Column.LANGUAGES].split(','), requestedAt: parseDateRow(row[Column.REQUESTED_AT]), dueBy: row[Column.DUE_BY], - reviewType: row[Column.REVIEW_TYPE], candidateIdentifier: row[Column.CANDIDATE_IDENTIFIER], reviewersNeededCount: Number(row[Column.REVIEWERS_NEEDED_COUNT]), acceptedReviewers: JSON.parse(row[Column.ACCEPTED_REVIEWERS]), @@ -51,7 +49,6 @@ function mapActiveReviewToRow(activeReview: ActiveReview): Record { [Column.LANGUAGES]: activeReview.languages.join(','), [Column.REQUESTED_AT]: activeReview.requestedAt.getTime(), [Column.DUE_BY]: activeReview.dueBy, - [Column.REVIEW_TYPE]: activeReview.reviewType, [Column.CANDIDATE_IDENTIFIER]: activeReview.candidateIdentifier, [Column.REVIEWERS_NEEDED_COUNT]: activeReview.reviewersNeededCount, [Column.ACCEPTED_REVIEWERS]: JSON.stringify(activeReview.acceptedReviewers), diff --git a/src/database/repos/reviewTypesRepo.ts b/src/database/repos/reviewTypesRepo.ts deleted file mode 100644 index 202ba94a..00000000 --- a/src/database/repos/reviewTypesRepo.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { database } from '@database'; -import { Language } from '@models/Language'; -import { GoogleSpreadsheetRow, GoogleSpreadsheetWorksheet } from 'google-spreadsheet'; - -enum Column { - TYPE = 'type', -} - -function mapRowsToReviewTypes(rows: GoogleSpreadsheetRow[]): Language[] { - return rows.map(mapRowToReviewType); -} - -function mapRowToReviewType(row: GoogleSpreadsheetRow): Language { - return { - name: row[Column.TYPE], - }; -} - -export const reviewTypesRepo = { - sheetTitle: 'review_types', - columns: Object.values(Column), - - openSheet(): Promise { - return database.openSheet(this.sheetTitle, this.columns); - }, - - async listAll(): Promise { - const sheet = await this.openSheet(); - const rows = await sheet.getRows(); - const reviewTypes = mapRowsToReviewTypes(rows); - - return [...reviewTypes.map(({ name }) => name).sort()]; - }, -}; diff --git a/src/services/ChatService.ts b/src/services/ChatService.ts index 9004a9f7..00dd82fe 100644 --- a/src/services/ChatService.ts +++ b/src/services/ChatService.ts @@ -90,7 +90,6 @@ export const chatService = { requestor: { id: string }, languages: string[], deadlineDisplay: string, - reviewType: string, ): Promise { const request = requestBuilder.buildReviewRequest( reviewerId, @@ -98,7 +97,6 @@ export const chatService = { requestor, languages, deadlineDisplay, - reviewType, ); const requestWithToken = { ...request, diff --git a/src/services/RequestService.ts b/src/services/RequestService.ts index 55ba34ab..5ed9ba0a 100644 --- a/src/services/RequestService.ts +++ b/src/services/RequestService.ts @@ -50,7 +50,6 @@ function moveOntoNextPerson(closeMessage: string) { { id: updatedReview.requestorId }, updatedReview.languages, DeadlineLabel.get(updatedReview.dueBy) || 'Unknown', - updatedReview.reviewType, ); const closeMessageBlock = textBlock(closeMessage); await chatService.updateDirectMessage( @@ -81,7 +80,6 @@ async function requestNextUserReview(review: ActiveReview, _client: WebClient): { id: review.requestorId }, review.languages, DeadlineLabel.get(review.dueBy) || '', - review.reviewType, ); const pendingReviewer: PendingReviewer = { ...nextUser, diff --git a/src/services/__tests__/ChatService.test.ts b/src/services/__tests__/ChatService.test.ts index c6ec0b13..5ded7e74 100644 --- a/src/services/__tests__/ChatService.test.ts +++ b/src/services/__tests__/ChatService.test.ts @@ -81,7 +81,6 @@ describe('ChatService', () => { { id: requestorId }, languages, DeadlineLabel.get(Deadline.END_OF_DAY) || '', - 'HackerRank', ); expect(client.chat.postMessage).toHaveBeenCalledWith({ diff --git a/src/services/__tests__/QueueService.test.ts b/src/services/__tests__/QueueService.test.ts index ff1646e7..e1c27da4 100644 --- a/src/services/__tests__/QueueService.test.ts +++ b/src/services/__tests__/QueueService.test.ts @@ -149,7 +149,6 @@ describe('Queue Service', () => { languages: ['Java'], requestedAt: new Date(), dueBy: Deadline.END_OF_DAY, - reviewType: 'HackerRank', candidateIdentifier: '123', reviewersNeededCount: 2, acceptedReviewers: [], diff --git a/src/services/__tests__/RequestService.test.ts b/src/services/__tests__/RequestService.test.ts index f6434df5..51c40a3d 100644 --- a/src/services/__tests__/RequestService.test.ts +++ b/src/services/__tests__/RequestService.test.ts @@ -23,7 +23,6 @@ describe('RequestService', () => { languages: ['Java'], requestedAt: new Date(), dueBy: Deadline.END_OF_DAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 2, acceptedReviewers: [acceptedUser('999')], @@ -48,7 +47,6 @@ describe('RequestService', () => { languages: ['Java'], requestedAt: requestedDate, dueBy: Deadline.END_OF_DAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 2, acceptedReviewers: [acceptedUser('999')], @@ -70,7 +68,6 @@ describe('RequestService', () => { languages: ['Java'], requestedAt: requestedDate, dueBy: Deadline.END_OF_DAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 2, acceptedReviewers: [ @@ -99,7 +96,6 @@ describe('RequestService', () => { languages: ['Java'], requestedAt: new Date(), dueBy: Deadline.END_OF_DAY, - reviewType: 'HackerRank', candidateIdentifier: '', reviewersNeededCount: 2, acceptedReviewers: [], @@ -148,7 +144,6 @@ describe('RequestService', () => { { id: review.requestorId }, review.languages, 'Today', - 'HackerRank', ); expect(reviewCloser.closeReviewIfComplete).toHaveBeenCalledWith(app, threadId); }); diff --git a/src/services/__tests__/ReviewActionService.test.ts b/src/services/__tests__/ReviewActionService.test.ts index caf1f393..f9f841e7 100644 --- a/src/services/__tests__/ReviewActionService.test.ts +++ b/src/services/__tests__/ReviewActionService.test.ts @@ -18,7 +18,6 @@ describe('ReviewActionService', () => { languages: ['Java'], requestedAt: new Date(1577858300000), dueBy: Deadline.END_OF_DAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 2, acceptedReviewers: [{ userId: 'A', acceptedAt: 1609480800000 }], diff --git a/src/services/__tests__/reviewCloser.test.ts b/src/services/__tests__/reviewCloser.test.ts index 35c66d57..f3e7553c 100644 --- a/src/services/__tests__/reviewCloser.test.ts +++ b/src/services/__tests__/reviewCloser.test.ts @@ -24,7 +24,6 @@ describe('reviewCloser', () => { languages: ['Java'], requestedAt: new Date(), dueBy: Deadline.MONDAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 2, acceptedReviewers: [acceptedUser('A'), acceptedUser('B')], @@ -53,7 +52,6 @@ describe('reviewCloser', () => { languages: ['Java'], requestedAt: new Date(), dueBy: Deadline.MONDAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 2, acceptedReviewers: [acceptedUser('B')], @@ -86,7 +84,6 @@ describe('reviewCloser', () => { languages: ['Java'], requestedAt: new Date(), dueBy: Deadline.MONDAY, - reviewType: 'HackerRank', candidateIdentifier: 'some-id', reviewersNeededCount: 2, acceptedReviewers: [acceptedUser('A')], diff --git a/src/utils/RequestBuilder.ts b/src/utils/RequestBuilder.ts index 411c4c00..9477b431 100644 --- a/src/utils/RequestBuilder.ts +++ b/src/utils/RequestBuilder.ts @@ -11,12 +11,11 @@ export const requestBuilder = { requestor: { id: string }, languages: string[], deadlineDisplay: string, - reviewType: string, ): any { return { channel: reviewerId, - text: `${reviewType} review requested`, - blocks: this.buildReviewBlocks(threadId, requestor, languages, deadlineDisplay, reviewType), + text: `HackerRank review requested`, + blocks: this.buildReviewBlocks(threadId, requestor, languages, deadlineDisplay), }; }, @@ -25,10 +24,9 @@ export const requestBuilder = { requestor: { id: string }, languages: string[], deadlineDisplay: string, - reviewType: string, ): Block[] { return [ - this.buildReviewSectionBlock(requestor, languages, deadlineDisplay, reviewType), + this.buildReviewSectionBlock(requestor, languages, deadlineDisplay), this.buildReviewActionsBlock(threadId), ]; }, @@ -37,7 +35,6 @@ export const requestBuilder = { requestor: { id: string }, languages: string[], deadlineDisplay: string, - reviewType: string, ): SectionBlock { return { block_id: BlockId.REVIEWER_DM_CONTEXT, @@ -47,7 +44,7 @@ export const requestBuilder = { text: compose( `${mention( requestor, - )} has requested a ${reviewType} review done in the following languages:`, + )} has requested a HackerRank review done in the following languages:`, ul(...languages), bold(`The review is needed by end of day ${deadlineDisplay}`), ),