Skip to content

Commit b076dd8

Browse files
author
ruiichen
committed
setup and pseudocode
1 parent ea91602 commit b076dd8

File tree

4 files changed

+92
-4
lines changed

4 files changed

+92
-4
lines changed

backend/typescript/graphql/resolvers/reviewDashboardResolvers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ReviewDashboardService from "../../services/implementations/reviewDashboardService";
2-
import { ReviewDashboardRowDTO } from "../../types";
2+
import { ReviewDashboardRowDTO, ReviewedApplicantRecordDTO } from "../../types";
33
import { getErrorMessage } from "../../utilities/errorUtils";
44

55
const reviewDashboardService = new ReviewDashboardService();
@@ -20,6 +20,15 @@ const reviewDashboardResolvers = {
2020
}
2121
},
2222
},
23+
Mutation: {
24+
delegateReviewers: async (): Promise<ReviewedApplicantRecordDTO[]> => {
25+
try {
26+
return await reviewDashboardService.delegateReviewers();
27+
} catch (error) {
28+
throw new Error(getErrorMessage(error));
29+
}
30+
},
31+
},
2332
};
2433

2534
export default reviewDashboardResolvers;

backend/typescript/graphql/types/reviewDashboardType.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { gql } from "apollo-server-express";
2-
import { ApplicationStatus, PositionTitle, ReviewerDTO } from "../../types";
2+
import {
3+
ApplicationStatus,
4+
PositionTitle,
5+
Review,
6+
ReviewerDTO,
7+
ReviewStatus,
8+
SkillCategory,
9+
} from "../../types";
310

411
const reviewDashboardType = gql`
512
type ReviewerDTO {
@@ -18,12 +25,33 @@ const reviewDashboardType = gql`
1825
totalScore: Int
1926
}
2027
28+
type Review {
29+
passionFSG: Int
30+
teamPlayer: Int
31+
desireToLearn: Int
32+
skill: Int
33+
skillCategory: String
34+
}
35+
36+
type ReviewedApplicantRecordDTO {
37+
applicantRecordId: String!
38+
reviewerId: Int!
39+
review: Review
40+
status: String!
41+
score: Int
42+
reviewerHasConflict: Boolean!
43+
}
44+
2145
extend type Query {
2246
reviewDashboard(
2347
pageNumber: Int!
2448
resultsPerPage: Int!
2549
): [ReviewDashboardRowDTO!]!
2650
}
51+
52+
extend type Mutation {
53+
delegateReviewers: [ReviewedApplicantRecordDTO!]!
54+
}
2755
`;
2856

2957
export default reviewDashboardType;

backend/typescript/services/implementations/reviewDashboardService.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { PositionTitle, ReviewDashboardRowDTO } from "../../types";
1+
import {
2+
PositionTitle,
3+
ReviewDashboardRowDTO,
4+
ReviewedApplicantRecordDTO,
5+
} from "../../types";
26
import IReviewDashboardService from "../interfaces/IReviewDashboardService";
37
import { getErrorMessage } from "../../utilities/errorUtils";
48
import logger from "../../utilities/logger";
@@ -72,6 +76,47 @@ class ReviewDashboardService implements IReviewDashboardService {
7276
throw error;
7377
}
7478
}
79+
80+
async delegateReviewers(): Promise<ReviewedApplicantRecordDTO[]> {
81+
// NOTE: We do not have to concern ourselves with locality. That is, each user can be
82+
// assigned to the same parter every time.
83+
84+
const FSM = new Map<string, [number, string[]]>();
85+
// maps (position title) => (current index of list, list of users with position_title)
86+
const delegations = new Map<string, [string, string]>();
87+
// maps (applicant_record_id) => pair of user_ids assigned to it
88+
89+
// STEP 1:
90+
// Populate the FSM
91+
// NOTE: need to add a sentinel value at the end of the list if the number of user is odd.
92+
// The last 'real' user will bear the burden of solo reviewing.
93+
94+
// STEP 2:
95+
// Round robin with the FSM
96+
/*
97+
for (auto& a : applicant_records) {
98+
pair<int,vector<string>>& position_entry = FSM[a.position];
99+
100+
// get first user
101+
string id1 = position_entry.second[position_entry.first];
102+
position_entry.first++;
103+
position_entry.first %= position_entry.second.size();
104+
105+
// get second user
106+
string id2 = position_entry.second[position_entry.first];
107+
position_entry.first++;
108+
position_entry.first %= position_entry.second.size();
109+
110+
delegations[a.id] = make_pair(id1, id2);
111+
}
112+
*/
113+
114+
// STEP 3:
115+
// Batch the delegations into ReviewedApplicantRecords
116+
// NOTE: do not add the sentinel value we inserted earlier.
117+
118+
return [];
119+
}
75120
}
76121

77122
export default ReviewDashboardService;

backend/typescript/services/interfaces/IReviewDashboardService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReviewDashboardRowDTO } from "../../types";
1+
import { ReviewDashboardRowDTO, ReviewedApplicantRecordDTO } from "../../types";
22

33
interface IReviewDashboardService {
44
/**
@@ -10,6 +10,12 @@ interface IReviewDashboardService {
1010
page: number,
1111
resultsPerPage: number,
1212
): Promise<ReviewDashboardRowDTO[]>;
13+
14+
/**
15+
* Assigns each user to an applicant record to review, and
16+
* returns the newly created ReviewedApplicantRecords
17+
*/
18+
delegateReviewers(): Promise<ReviewedApplicantRecordDTO[]>;
1319
}
1420

1521
export default IReviewDashboardService;

0 commit comments

Comments
 (0)