Skip to content

Commit 691cab4

Browse files
authored
Merge pull request #70 from PentabyteDevAlign/refactor
Refactor
2 parents b60963e + 9b904ca commit 691cab4

6 files changed

Lines changed: 1223 additions & 258 deletions

File tree

AI/src/api/roster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ def get_recommendations(request: SkillRequest):
240240
print("Proyek gweh: ", project_count)
241241

242242
if project_count == 0:
243-
project_count_score = 1.0
244-
elif project_count >= 5:
245243
project_count_score = 0.0
244+
elif project_count >= 5:
245+
project_count_score = 1.0
246246
else:
247247
# menurun 0.2 tiap project
248-
project_count_score = 1.0 - (project_count * 0.2)
248+
project_count_score = project_count * 0.2
249249
logs["workload_calculation_time"] += time.time() - start_time
250250

251251
# 3. Embedding vector

Backend/controllers/hr.controller.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,42 @@ const listEmployees = async (req, res) => {
203203
.limit(limit)
204204
.exec();
205205

206-
// Count projects per user for users in this page
207206
const userIds = users.map((u) => u._id);
207+
208208
const projectCountsMap = new Map();
209+
const activeCountsMap = new Map();
210+
209211
if (userIds.length > 0) {
210212
const counts = await ProjectAssignment.aggregate([
211213
{ $match: { userId: { $in: userIds } } },
212214
{ $group: { _id: "$userId", count: { $sum: 1 } } },
213215
]).exec();
214216
counts.forEach((c) => projectCountsMap.set(String(c._id), c.count));
217+
218+
const activeCounts = await ProjectAssignment.aggregate([
219+
{ $match: { userId: { $in: userIds } } },
220+
{
221+
$lookup: {
222+
from: "projects",
223+
localField: "projectId",
224+
foreignField: "_id",
225+
as: "project",
226+
},
227+
},
228+
{ $unwind: "$project" },
229+
{ $match: { "project.status": "active" } },
230+
{ $group: { _id: "$userId", activeCount: { $sum: 1 } } },
231+
]).exec();
232+
233+
activeCounts.forEach((c) =>
234+
activeCountsMap.set(String(c._id), c.activeCount)
235+
);
215236
}
216237

217238
const mapped = users.map((u) => {
218239
const out = userDto.mapUserToUserResponse(u);
219240
out.projectCount = projectCountsMap.get(String(u._id)) || 0;
241+
out.activeProjectCount = activeCountsMap.get(String(u._id)) || 0;
220242
return out;
221243
});
222244

0 commit comments

Comments
 (0)