Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

My Gigs 2nd Week PROD Release #172

Merged
merged 28 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
182e489
UI Update finish
LieutenantRoger Jul 24, 2021
4e6396a
adjust duration
LieutenantRoger Jul 24, 2021
aa44583
ui optimize
LieutenantRoger Jul 24, 2021
e013a47
fix remark
LieutenantRoger Jul 24, 2021
f8fec69
field calculation
LieutenantRoger Jul 27, 2021
f2cd91a
agg API update
LieutenantRoger Jul 29, 2021
c0b1932
api adjustment
LieutenantRoger Jul 29, 2021
e995a6f
update swagger
LieutenantRoger Jul 29, 2021
a5fcd04
UI Update
LieutenantRoger Jul 29, 2021
4c918a1
Adjust icon
LieutenantRoger Jul 29, 2021
2389450
Merge branch 'gigs-new-ui' into gigs-filter
LieutenantRoger Jul 30, 2021
6993f97
sort completed and withdrawn
LieutenantRoger Jul 30, 2021
823e313
Merge branch 'gigs-new-ui' into gigs-filter
LieutenantRoger Jul 30, 2021
9e08983
fix: remark tooltip
LieutenantRoger Jul 30, 2021
910927b
cache data done
LieutenantRoger Jul 30, 2021
a66edc9
add badges
LieutenantRoger Jul 31, 2021
df8561a
fix: bucket selection
LieutenantRoger Jul 31, 2021
d4782b6
save page
LieutenantRoger Jul 31, 2021
5c628ec
cache data added
LieutenantRoger Jul 31, 2021
bec1856
restore per page
LieutenantRoger Jul 31, 2021
f075ce0
UI fix
LieutenantRoger Jul 31, 2021
a97504b
fix: empty text
LieutenantRoger Jul 31, 2021
8e81f9c
adjust the height
LieutenantRoger Aug 2, 2021
cb61638
restore ci
LieutenantRoger Aug 3, 2021
f4a6a81
clean up code
LieutenantRoger Aug 3, 2021
55bcac3
Merge pull request #171 from topcoder-platform/gigs-filter
LieutenantRoger Aug 5, 2021
8d922ce
handle unknown status
LieutenantRoger Aug 8, 2021
4d4d5c5
Merge pull request #173 from topcoder-platform/gigs-filter
LieutenantRoger Aug 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
agg API update
  • Loading branch information
LieutenantRoger committed Jul 29, 2021
commit f2cd91a76e10c9196df26694763d82a64cbf560e
61 changes: 57 additions & 4 deletions src/api/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const _ = require("lodash");
const config = require("config");
const constants = require("../app-constants");
const logger = require("./logger");
const { weekDiff } = require("./utils");
const httpStatus = require("http-status");
const Interceptor = require("express-interceptor");
const m2mAuth = require("tc-core-library-js").auth.m2m;
Expand Down Expand Up @@ -300,7 +299,7 @@ async function getJobCandidates(criteria) {
* @param {*} userId
* @returns
*/
async function handlePlacedJobCandidates(jobCandidates, userId) {
async function handlePlacedJobCandidates(jobCandidates, userId, userHandle) {
if (!jobCandidates || jobCandidates.length == 0 || !userId) {
return;
}
Expand Down Expand Up @@ -346,17 +345,71 @@ async function handlePlacedJobCandidates(jobCandidates, userId) {
new Date(rb.endDate).toDateString() != new Date().toDateString()
) {
jc.status = "completed";
jc.rbPay = rb.memberRate;
jc.rbStartDate = rb.startDate;
jc.rbEndDate = rb.endDate;
jc.rbDuration = weekDiff(rb.startDate, rb.endDate);
jc.rbId = rb.id;
jc.userHandle = userHandle;
}
}
}
});
await getWorkingPeriods(jobCandidates, userHandle, rbRes);
return;
}

/**
* Get payment Total for working period
*
* @param {*} jobCandidates job candidates we will process
* @param {*} userHandle the user's handle
* @param {*} resourceBookings the resource booking belongs to this user
* @returns
*/
async function getWorkingPeriods(jobCandidates, userHandle, resourceBookings) {
if (
!userHandle ||
!resourceBookings ||
resourceBookings.length == 0 ||
!jobCandidates ||
jobCandidates.length == 0
) {
return;
}
const rbIds = resourceBookings.map((item) => item.id);
const token = await getM2MToken();
const url = `${config.API.V5}/work-periods`;
const criteria = {
userHandle: userHandle,
resourceBookingIds: rbIds.join(","),
};
const res = await request
.get(url)
.query(criteria)
.set("Authorization", `Bearer ${token}`)
.set("Accept", "application/json");
localLogger.debug({
context: "getWorkingPeriods",
message: `response body: ${JSON.stringify(res.body)}`,
});
if (res.body && res.body.length == 0) {
return;
}
// All the working periods for the rbs.
const wpRes = res.body;
_.each(rbIds, (rbId) => {
const wps = wpRes.filter(
(wp) => wp.userHandle == userHandle && wp.resourceBookingId == rbId
);
const paymentTotal = wps.reduce((total, wp) => total + wp.paymentTotal, 0);
const jc = jobCandidates.find(
(item) => item.rbId == rbId && item.userHandle == userHandle
);
if (jc) {
jc.paymentTotal = paymentTotal;
}
});
}

/**
* Return jobs by given criteria
* @param {string} criteria the search criteria
Expand Down
20 changes: 0 additions & 20 deletions src/api/common/utils.js

This file was deleted.

16 changes: 9 additions & 7 deletions src/api/services/JobApplicationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ async function getMyJobApplications(currentUser, criteria) {
return emptyResult;
}
// get user id by calling taas-api with current user's token
const { id: userId } = await helper.getCurrentUserDetails(
const { id: userId, handle: userHandle } = await helper.getCurrentUserDetails(
currentUser.jwtToken
);
if (!userId) {
if (!userId || !userHandle) {
throw new errors.NotFoundError(
`Id for user: ${currentUser.userId} not found`
`Id for user: ${currentUser.userId} or handle for user: ${currentUser.handle} not found`
);
}
// get jobCandidates of current user by calling taas-api
Expand All @@ -54,7 +54,11 @@ async function getMyJobApplications(currentUser, criteria) {
let jcResult = jobCandidates.result;
// handle placed status for completed_jobs, archived_jobs query
if (status && (status == "active_jobs" || status == "completed_jobs")) {
await helper.handlePlacedJobCandidates(jobCandidates.result, userId);
await helper.handlePlacedJobCandidates(
jobCandidates.result,
userId,
userHandle
);
if (status == "completed_jobs") {
jcResult = jobCandidates.result.filter(
(item) => item.status == "completed"
Expand All @@ -76,11 +80,9 @@ async function getMyJobApplications(currentUser, criteria) {
const job = _.find(jobs, ["id", jobCandidate.jobId]);
return {
title: job.title,
description: job.description,
rbPay: jobCandidate.rbPay,
paymentTotal: jobCandidate.paymentTotal,
rbStartDate: jobCandidate.rbStartDate,
rbEndDate: jobCandidate.rbEndDate,
rbDuration: jobCandidate.rbDuration,
payment: {
min: job.minSalary,
max: job.maxSalary,
Expand Down