Skip to content

Commit

Permalink
Merge commit '534669b79e552c9f8bed87e2d6e01bb95ed66cdb'
Browse files Browse the repository at this point in the history
  • Loading branch information
phuonghuynh committed Feb 3, 2016
2 parents 6d0a5d5 + 534669b commit f8db5d3
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/techlooper/cron/JobAlertEmailSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public class JobAlertEmailSender {

private final static Logger LOGGER = LoggerFactory.getLogger(JobAlertEmailSender.class);

private static final Integer OTHER_JOB_SOURCE_SIZE = 6;

private static final Integer VIETNAMWORKS_JOB_SOURCE_SIZE = 4;

private static final String VIETNAMWORKS_CRAWL_SOURCE = "vietnamworks";

@Value("${jobAlert.enable}")
private Boolean enableJobAlert;

Expand Down Expand Up @@ -69,7 +75,13 @@ public synchronized void sendJobAlertEmail() throws Exception {
if (daysBetween(lastSentDate, currentDate) > 0) {
JobSearchCriteria criteria = dozerMapper.map(jobAlertRegistrationEntity, JobSearchCriteria.class);
criteria.setFromJobAlert(true);
criteria.setCrawlSource(VIETNAMWORKS_CRAWL_SOURCE);
criteria.setSize(VIETNAMWORKS_JOB_SOURCE_SIZE);
JobSearchResponse jobSearchResponse = jobAggregatorService.findJob(criteria);

criteria.setSize(OTHER_JOB_SOURCE_SIZE);
jobSearchResponse.addJobs(jobAggregatorService.findJob(criteria).getJobs());

if (jobSearchResponse.getTotalJob() > 0) {
jobAggregatorService.sendEmail(jobAlertRegistrationEntity, jobSearchResponse);
jobAggregatorService.updateSendEmailResultCode(jobAlertRegistrationEntity, EMAIL_SENT);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/techlooper/model/ChallengeDashBoardInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class ChallengeDashBoardInfo {

private List<ChallengeSubmissionEntity> submissions;

private JobSeekerPhaseEnum jobSeekerPhase;

public Long getChallengeId() {
return challengeId;
}
Expand Down Expand Up @@ -141,6 +143,14 @@ public void setChallengeType(ChallengeTypeEnum challengeType) {
this.challengeType = challengeType;
}

public JobSeekerPhaseEnum getJobSeekerPhase() {
return jobSeekerPhase;
}

public void setJobSeekerPhase(JobSeekerPhaseEnum jobSeekerPhase) {
this.jobSeekerPhase = jobSeekerPhase;
}

public static class Builder {

private ChallengeDashBoardInfo challengeDashBoardInfo = new ChallengeDashBoardInfo();
Expand Down Expand Up @@ -210,6 +220,11 @@ public Builder withChallengeType(ChallengeTypeEnum challengeType) {
return this;
}

public Builder withJobSeekerPhase(JobSeekerPhaseEnum jobSeekerPhase) {
challengeDashBoardInfo.setJobSeekerPhase(jobSeekerPhase);
return this;
}

public ChallengeDashBoardInfo build() {
return challengeDashBoardInfo;
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/techlooper/model/JobSearchCriteria.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class JobSearchCriteria {

private boolean fromJobAlert;

private Integer size;

public JobSearchCriteria() {
this.page = 1;
}
Expand Down Expand Up @@ -82,4 +84,12 @@ public boolean isFromJobAlert() {
public void setFromJobAlert(boolean fromJobAlert) {
this.fromJobAlert = fromJobAlert;
}

public Integer getSize() {
return size;
}

public void setSize(Integer size) {
this.size = size;
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/techlooper/model/JobSearchResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ public List<JobResponse> getJobs() {
public void setJobs(List<JobResponse> jobs) {
this.jobs = jobs;
}

public void addJobs(List<JobResponse> jobs) {
if (this.jobs == null) {
this.jobs = new ArrayList<>();
}
this.jobs.addAll(jobs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,13 @@ public List<ChallengeDashBoardInfo> getChallengeDashBoardInfo(JobSeekerDashBoard
challengeDashBoardInfoBuilder.withCriteria(registrantEntity.getCriteria());
challengeDashBoardInfoBuilder.withSubmissions(challengeSubmissionService.findChallengeSubmissionByRegistrant(registrantId));
challengeDashBoardInfoBuilder.withChallengeType(challengeEntity.getChallengeType());
challengeDashBoardInfoBuilder.withJobSeekerPhase(getJobSeekerPhase(challengeEntity, registrantEntity));
challengeDashBoardInfoList.add(challengeDashBoardInfoBuilder.build());
}
}
return challengeDashBoardInfoList;
return challengeDashBoardInfoList.stream()
.sorted((source, destination) -> source.getJobSeekerPhase().getOrder() - destination.getJobSeekerPhase().getOrder())
.collect(toList());
}

private boolean isPhaseMatching(ChallengeEntity challengeEntity, ChallengeRegistrantEntity registrantEntity,
Expand All @@ -490,6 +493,21 @@ private boolean isPhaseMatching(ChallengeEntity challengeEntity, ChallengeRegist
}
}

private JobSeekerPhaseEnum getJobSeekerPhase(ChallengeEntity challengeEntity, ChallengeRegistrantEntity registrantEntity) {
ChallengePhaseEnum jobSeekerCurrentPhase = registrantEntity.getActivePhase() == null ?
REGISTRATION : registrantEntity.getActivePhase();
List<ChallengePhaseEnum> activePhases = Arrays.asList(REGISTRATION, IDEA, UIUX, PROTOTYPE, FINAL);
boolean isChallengeClosed = daysBetween(challengeEntity.getSubmissionDateTime(), currentDate()) > 0;

if (!isChallengeClosed && activePhases.contains(jobSeekerCurrentPhase)) {
return JobSeekerPhaseEnum.ACTIVE;
} else if (registrantEntity.getDisqualified() != null && registrantEntity.getDisqualified()) {
return JobSeekerPhaseEnum.DISQUALIFIED;
} else {
return JobSeekerPhaseEnum.FINISHED;
}
}

public Set<ChallengeRegistrantDto> getChallengeWinners(Long challengeId) {
ChallengeEntity challenge = challengeRepository.findOne(challengeId);
if (Boolean.TRUE.equals(challenge.getVisibleWinners())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private ScrapeJobEntity convertToJobEntity(VNWJobSearchResponseDataItem job, Boo
}

private NativeSearchQueryBuilder getJobListingQueryBuilder(JobSearchCriteria criteria) {
final int NUMBER_OF_ITEMS_PER_PAGE = 10;
final int NUMBER_OF_ITEMS_PER_PAGE = criteria.getSize() != null ? criteria.getSize() : 10;
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("job");

QueryBuilder queryBuilder = null;
Expand All @@ -310,6 +310,11 @@ private NativeSearchQueryBuilder getJobListingQueryBuilder(JobSearchCriteria cri
BoolFilterBuilder filterBuilder = new BoolFilterBuilder();
filterBuilder.mustNot(termFilter("isActive", 0));
filterBuilder.must(rangeFilter("createdDateTime").from("now-30d/d"));

if (StringUtils.isNotEmpty(criteria.getCrawlSource())) {
filterBuilder.must(termFilter("crawlSource", criteria.getCrawlSource()));
}

if (criteria.getTopPriority() != null) {
if (criteria.getTopPriority()) {
filterBuilder.must(termFilter("topPriority", true));
Expand Down

0 comments on commit f8db5d3

Please sign in to comment.