Skip to content

Commit

Permalink
Merge pull request #485 from khoa-nd/master
Browse files Browse the repository at this point in the history
Merged
  • Loading branch information
khoa-nd committed Jan 13, 2016
2 parents 62905f7 + 1c2f39c commit acf5cac
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.techlooper.controller;

import com.techlooper.entity.JobEntity;
import com.techlooper.model.*;
import com.techlooper.repository.JsonConfigRepository;
import com.techlooper.service.JobSearchService;
import com.techlooper.service.JobStatisticService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.*;

import static java.util.stream.Collectors.toList;

@RestController
public class JobStatisticController {
Expand All @@ -33,6 +32,9 @@ public class JobStatisticController {
@Resource
private JobStatisticService jobStatisticService;

@Resource
private JobSearchService jobSearchService;

private final static List<Integer> JOB_LEVEL_ALL = Collections.EMPTY_LIST;

@Scheduled(cron = "${scheduled.cron}")
Expand Down Expand Up @@ -91,4 +93,22 @@ public GetPromotedResponse getTopDemandedSkills(@RequestBody GetPromotedRequest
return jobStatisticService.getTopDemandedSkillsByJobTitle(getPromotedRequest);
}

@CrossOrigin
@RequestMapping(value = "/getPromotedWidget", method = RequestMethod.POST)
public GetPromotedResponse getTopDemandedSkillsWidget(@RequestBody GetPromotedRequest getPromotedRequest) {
setPriceJobConditionFromJobId(getPromotedRequest);
return jobStatisticService.getTopDemandedSkillsByJobTitle(getPromotedRequest);
}

private void setPriceJobConditionFromJobId(GetPromotedRequest getPromotedRequest) {
if (StringUtils.isNotEmpty(getPromotedRequest.getTechlooperJobId())) {
JobEntity job = jobSearchService.findJobById(getPromotedRequest.getTechlooperJobId());
if (job != null) {
getPromotedRequest.setJobTitle(job.getJobTitle());
getPromotedRequest.setJobCategoryIds(job.getIndustries().stream().map(industry -> industry.getIndustryId()).collect(toList()));
getPromotedRequest.setJobLevelIds(Arrays.asList(job.getJobLevelId().intValue()));
}
}
}

}
11 changes: 11 additions & 0 deletions src/main/java/com/techlooper/entity/JobEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class JobEntity {
@Field(type = Boolean)
private Boolean isSalaryVisible;

@Field(type = Long)
private Long jobLevelId;

public String getId() {
return id;
}
Expand Down Expand Up @@ -130,6 +133,14 @@ public void setIsSalaryVisible(Boolean isSalaryVisible) {
this.isSalaryVisible = isSalaryVisible;
}

public Long getJobLevelId() {
return jobLevelId;
}

public void setJobLevelId(Long jobLevelId) {
this.jobLevelId = jobLevelId;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/techlooper/model/GetPromotedRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class GetPromotedRequest {

private String campaign;

private String techlooperJobId;

public String getJobTitle() {
return jobTitle;
}
Expand Down Expand Up @@ -56,4 +58,12 @@ public String getCampaign() {
public void setCampaign(String campaign) {
this.campaign = campaign;
}

public String getTechlooperJobId() {
return techlooperJobId;
}

public void setTechlooperJobId(String techlooperJobId) {
this.techlooperJobId = techlooperJobId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SalaryReviewServiceImpl implements SalaryReviewService {

private static final int TWO_PERCENTILES = 2;

private static final int LIMIT_NUMBER_OF_JOBS_FOR_SALARY_REVIEW = 1000;
private static final int LIMIT_NUMBER_OF_JOBS_FOR_SALARY_REVIEW = 300;

private static final double[] percents = new double[]{10D, 25D, 50D, 75D, 90D};

Expand Down Expand Up @@ -147,9 +147,10 @@ public SalaryReviewResultDto reviewSalary(SalaryReviewDto salaryReviewDto) {
jobRepository.addStrategy(searchByTitleStrategy);
}

int originalNumberOfJobs = jobRepository.getJobs().size();
Set<JobEntity> jobForReview = jobRepository.getJobs().stream().limit(LIMIT_NUMBER_OF_JOBS_FOR_SALARY_REVIEW).collect(toSet());

SalaryReviewResultDto salaryReviewResult = generateSalaryReport(salaryReviewDto, jobForReview);
SalaryReviewResultDto salaryReviewResult = generateSalaryReport(salaryReviewDto, jobForReview, originalNumberOfJobs);
return salaryReviewResult;
}

Expand Down Expand Up @@ -197,7 +198,7 @@ private String chooseTheBestJobTitle(List<String> normalizedJobTitleCandidates)
return null;
}

private SalaryReviewResultDto generateSalaryReport(SalaryReviewDto salaryReviewDto, Set<JobEntity> jobs) {
private SalaryReviewResultDto generateSalaryReport(SalaryReviewDto salaryReviewDto, Set<JobEntity> jobs, int originalNumberOfJobs) {
SalaryReport salaryReport = new SalaryReport();
salaryReport.setNetSalary(salaryReviewDto.getNetSalary());

Expand All @@ -222,7 +223,7 @@ private SalaryReviewResultDto generateSalaryReport(SalaryReviewDto salaryReviewD
percentRank = calculatePercentPosition(salaryReport);
}
salaryReport.setPercentRank(Math.floor(percentRank));
salaryReport.setNumberOfJobs(jobs.size());
salaryReport.setNumberOfJobs(originalNumberOfJobs);

SalaryReviewResultDto salaryReviewResult = dozerMapper.map(salaryReviewDto, SalaryReviewResultDto.class);
salaryReviewResult.setSalaryReport(salaryReport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<#if passCode??>
<tr>
<td width="30%" align="left" style="padding-right: 5px">
Password:
Passcode:
</td>
<td width="70%" align="left">
<strong>${passCode}</strong>
Expand Down Expand Up @@ -338,7 +338,7 @@
</tr>
<tr>
<td>
<img src="${webBaseUrl}images/submission-form.png" alt="" style="width:100%">
<img src="${webBaseUrl}images/submission-internal-form.png" alt="" style="width:100%">
</td>
</tr>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<#if passCode??>
<tr>
<td width="30%" align="left" style="padding-right: 5px">
Mật Khẩu:
Mã xác nhận:
</td>
<td width="70%" align="left">
<strong>${passCode}</strong>
Expand Down Expand Up @@ -338,7 +338,7 @@
</tr>
<tr>
<td>
<img src="${webBaseUrl}images/submission-form-vi.png" alt="" style="width:100%">
<img src="${webBaseUrl}images/submission-internal-form-vi.png" alt="" style="width:100%">
</td>
</tr>
</table>
Expand Down
Binary file removed src/main/webapp/assets/images/submission-form-vi.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/main/webapp/assets/modules/job-listing/job-listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h2 translate="ItJobHub"></h2>
<h4><a href="/#/?action=redirectJA&targetUrl={{job.url}}" target="_blank">{{job.title}}</a></h4>
<ul class="info">
<li class="date"><i class="fa fa-calendar"></i><span>{{job.postedOn}}</span></li>
<li class="location"><i class="fa fa-map-marker"></i><span>{{job.locationText}}</span></li>
<li class="location" ng-if="job.locationText.length"><i class="fa fa-map-marker"></i><span>{{job.locationText}}</span></li>
</ul>
<p><i class="fa fa-money"></i><span translate="salary"></span>:
<strong ng-show="!job.salary">{{'negotiable' | translate}}</strong>
Expand Down Expand Up @@ -114,7 +114,7 @@ <h4><a href="/#/?action=redirectJA&targetUrl={{job.url}}" target="_blank">{{job.
<h4><a href="/#/?action=redirectJA&targetUrl={{job.url}}" target="_blank">{{job.title}}</a></h4>
<ul class="info">
<li class="date"><i class="fa fa-calendar"></i><span>{{job.postedOn}}</span></li>
<li class="location"><i class="fa fa-map-marker"></i><span>{{job.locationText}}</span></li>
<li class="location" ng-if="job.locationText.length"><i class="fa fa-map-marker"></i><span>{{job.locationText}}</span></li>
</ul>
<p><i class="fa fa-money"></i><span translate="salary"></span>:
<strong ng-show="!job.salary">{{'negotiable' | translate}}</strong>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/assets/modules/translation/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,8 @@
"enterYourEmail": "Enter your email",
"signInInternalChallengeTitle": "First, Let Us Know Who You Are",
"emailChallengeFormat": "Sign in using your registered email address and password for this challenge.",
"passCode": "Pass Code: <strong>*</strong>",
"enterYourPassCode": "Enter your pass code",
"passCode": "Passcode: <strong>*</strong>",
"enterYourPassCode": "Enter your passcode",
"domainLabel": "Domains:",
"invalidCredential": "Invalid credential",
"invalidMinlengthDigits": "This field can not less than {{length}} digits",
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/assets/modules/translation/messages_vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -896,5 +896,7 @@
"domainLabel": "Tên miền:",
"invalidCredential": "Tài khoản không hợp lệ",
"invalidMinlengthDigits": "Trường này không được nhỏ hơn 4 ký số",
"emailSentSuccessfully": "Email đã gửi thành công."
"emailSentSuccessfully": "Email đã gửi thành công.",
"passCode": "Mã xác nhận: <strong>*</strong>",
"enterYourPassCode": "Nhập mã xác nhận"
}

0 comments on commit acf5cac

Please sign in to comment.