Skip to content

Commit

Permalink
Merge pull request #495 from khoa-nd/master
Browse files Browse the repository at this point in the history
Merged
  • Loading branch information
khoa-nd committed Jan 21, 2016
2 parents 5e97991 + 609506e commit b31e924
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public JobAlertRegistrationEntity registerJobAlert(@RequestBody JobAlertRegistra

//Send list of jobs that matches user's criteria immediately after user submitted registration form
JobSearchCriteria criteria = dozerMapper.map(jobAlertRegistrationEntity, JobSearchCriteria.class);
criteria.setFromJobAlert(true);
JobSearchResponse jobSearchResponse = jobAggregatorService.findJob(criteria);
if (jobSearchResponse.getTotalJob() > 0) {
try {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/techlooper/cron/JobAlertEmailSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public synchronized void sendJobAlertEmail() throws Exception {

if (daysBetween(lastSentDate, currentDate) > 0) {
JobSearchCriteria criteria = dozerMapper.map(jobAlertRegistrationEntity, JobSearchCriteria.class);
criteria.setFromJobAlert(true);
JobSearchResponse jobSearchResponse = jobAggregatorService.findJob(criteria);
if (jobSearchResponse.getTotalJob() > 0) {
jobAggregatorService.sendEmail(jobAlertRegistrationEntity, jobSearchResponse);
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 @@ -17,6 +17,8 @@ public class JobSearchCriteria {

private String crawlSource;

private boolean fromJobAlert;

public JobSearchCriteria() {
this.page = 1;
}
Expand Down Expand Up @@ -72,4 +74,12 @@ public Integer getLocationId() {
public void setLocationId(Integer locationId) {
this.locationId = locationId;
}

public boolean isFromJobAlert() {
return fromJobAlert;
}

public void setFromJobAlert(boolean fromJobAlert) {
this.fromJobAlert = fromJobAlert;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public List<ChallengeDashBoardInfo> getChallengeDashBoardInfo(String registrantE
Long registrantId = registrantEntity.getRegistrantId();
ChallengeEntity challengeEntity = challengeService.findChallengeById(challengeId);

if (challengeEntity != null) {
if (challengeEntity != null && (challengeEntity.getExpired() == null || challengeEntity.getExpired() == false)) {
ChallengeDashBoardInfo.Builder challengeDashBoardInfoBuilder = new ChallengeDashBoardInfo.Builder();
challengeDashBoardInfoBuilder.withChallengeId(challengeId);
challengeDashBoardInfoBuilder.withChallengeName(challengeEntity.getChallengeName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ public JobSearchResponse findJob(JobSearchCriteria criteria) {
List<ScrapeJobEntity> jobs = scrapeJobRepository.search(searchQueryBuilder.build()).getContent();
List<JobResponse> result = getJobResponses(jobs);

if (criteria.getPage() == 1) {
searchQueryBuilder = getVietnamworksJobQueryBuilder(criteria);
List<ScrapeJobEntity> vietnamworksJobs = scrapeJobRepository.search(searchQueryBuilder.build()).getContent();
List<JobResponse> vietnamworksJobResult = getJobResponses(vietnamworksJobs);
result.addAll(0, vietnamworksJobResult);
totalJob += vietnamworksJobs.size();
searchQueryBuilder = getVietnamworksJobQueryBuilder(criteria);
FacetedPage<ScrapeJobEntity> vietnamworksJobsSearchResult = scrapeJobRepository.search(searchQueryBuilder.build());
totalJob += vietnamworksJobsSearchResult.getTotalElements();

if (criteria.getPage() == 1 || criteria.isFromJobAlert()) {
List<ScrapeJobEntity> vietnamworksJobs = vietnamworksJobsSearchResult.getContent();
result.addAll(0, getJobResponses(vietnamworksJobs));
}

JobSearchResponse jobSearchResponse = new JobSearchResponse.Builder()
Expand Down Expand Up @@ -298,7 +299,10 @@ private ScrapeJobEntity convertToJobEntity(VNWJobSearchResponseDataItem job, Boo
}

private NativeSearchQueryBuilder getJobListingQueryBuilder(JobSearchCriteria criteria) {
final int NUMBER_OF_ITEMS_PER_PAGE = 10;
int NUMBER_OF_ITEMS_PER_PAGE = 10;
if (criteria.getPage() == 1) {
NUMBER_OF_ITEMS_PER_PAGE = 6;
}
NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withTypes("job");

QueryBuilder queryBuilder = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,84 @@
techlooper.filter("jobseekerDashboardChallenge", function ($filter, $translate) {
techlooper.filter("jobseekerDashboardChallenge", function ($filter, $translate, utils, jsonValue) {
return function (input, type) {
if (!input || input.$isRich) return input;

var challenge = input;

challenge.recalculate = function () {
var currentPhaseLowerCase = challenge.currentPhase.toLowerCase();
challenge.$currentPhaseLowerCase = currentPhaseLowerCase;
challenge.$currentPhaseTitle = $filter("translate")(currentPhaseLowerCase);

challenge.$asciiChallengeName = utils.toAscii(challenge.challengeName);
challenge.recalculatePhase();
challenge.recalculateCriteria();
challenge.recalculateAward();
challenge.recalculateSubmissions();
challenge.recalculateDaysLeft();
};

challenge.recalculateDaysLeft = function() {
challenge.recalculatePhase = function () {
var currentPhaseLowerCase = challenge.currentPhase.toLowerCase();
challenge.$currentPhaseLowerCase = currentPhaseLowerCase;
challenge.$currentPhaseTitle = $filter("translate")(currentPhaseLowerCase).toUpperCase();

challenge.$submissionMdate = moment(challenge.submissionDate, jsonValue.dateFormat);

var finishDaysLeft = utils.toNow(challenge.$submissionMdate);
challenge.$daysLeftTitle = finishDaysLeft > 0 ? $filter("translate")("daysLeft", {days: finishDaysLeft}) :
$filter("translate")("finishedOn", {date: challenge.submissionDate});

if (challenge.disqualified == true) {
challenge.$currentPhaseLowerCase = "disqualified";
challenge.$currentPhaseDescTitle = $filter("translate")("inPhase", {phase: challenge.$currentPhaseTitle});
challenge.$currentPhaseTitle = $filter("translate")("disqualified").toUpperCase();
}
else {
challenge.$currentPhaseSubmissionDate = moment(challenge.currentPhaseSubmissionDate, jsonValue.dateFormat);
var submitDaysLeft = utils.toNow(challenge.$currentPhaseSubmissionDate);
challenge.$currentPhaseDescTitle = finishDaysLeft <= 0 ? undefined : $filter("translate")("daysLeftToSubmit", {days: submitDaysLeft});
}
};

challenge.recalculateSubmissions = function() {
_.each(challenge.submissions, function(submission) {
challenge.recalculateSubmissions = function () {
_.each(challenge.submissions, function (submission) {
submission.$submissionURL = /^https?:\/\//.test(submission.submissionURL) ? submission.submissionURL : "http://" + submission.submissionURL;
submission.$phaseTitle = $filter("translate")(submission.submissionPhase.toLowerCase());
submission.submissionPhase && (submission.$phaseTitle = $filter("translate")(submission.submissionPhase.toLowerCase()));
});
};

challenge.recalculateAward = function() {
challenge.recalculateAward = function () {
challenge.$awardLowercase = "price-" + challenge.rank;
$.isNumeric(challenge.prize) && (challenge.$awardPrizeTitle = "$" + $filter("number")(challenge.prize));
};

//TODO refactor
challenge.recalculateCriteria = function () {
var totalPoints = 0.0;
_.each(challenge.criteria, function(cri) {
_.each(challenge.criteria, function (cri) {
var points = (cri.weight / 100) * cri.score;
cri.$score = cri.score || 0;
cri.$points = numeral(points).format("0.0");
totalPoints += points;
});

challenge.$totalPoints = numeral(totalPoints).format("0.0");
challenge.$hasSomeScore = _.some(challenge.criteria, function (cri) {return cri.score != null;});
};

challenge.$toggle = {
reset: function() {
reset: function () {
challenge.$toggleType = false;
},

toggleCriteria: function() {
toggleCriteria: function () {
challenge.$toggleType = "criteria";
},

isToggleCriteria: function() {
isToggleCriteria: function () {
return challenge.$toggleType == "criteria";
},

toggleSubmissions: function() {
toggleSubmissions: function () {
challenge.$toggleType = "submissions";
},

isToggleSubmissions: function() {
isToggleSubmissions: function () {
return challenge.$toggleType == "submissions";
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/assets/modules/common/utils.fac.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ techlooper.factory("utils", function (jsonValue, $location, $rootScope, localSto

var instance = {

toNow: function(mdate) {
return mdate.isSame(moment(), "day") ? 1 : mdate.diff(moment(), "days") + 2;
},

sortByArrayLength: function (array, numberField, type) {
return array.sort(function (left, right) {
if (!left || !right) return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h3 translate="myProfile"></h3>
<span translate="fullName"></span>{{$root.userInfo.name}}
</li>
<li>
<span translate="emailAddress"></span>{{$root.userInfo.email}}
<span>{{'emailAddress' | translate}}:</span>{{$root.userInfo.email}}
</li>
</ul>
</div>
Expand All @@ -40,35 +40,39 @@ <h3 translate="myProfile"></h3>
<div class="col-sm-4 challenge-name-col" translate="challenge"></div>
<div class="col-sm-2 current-phase-col" translate="myCurrentPhase"></div>
<div class="col-sm-2 submission-col" translate="submission"></div>
<div class="col-sm-2 score-col" translate="score"></div>
<div class="col-sm-1 prize-col" translate="prize"></div>
<div class="col-sm-1 prize-col"></div>
<div class="col-sm-2 score-col" translate="scoreLabel"></div>
<div class="col-sm-2 prize-col" translate="prize"></div>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="challenge in dashboardInfo.challenges" class="{{challenge.$awardLowercase}}">
<tr ng-if="!dashboardInfo.challenges.length">
<td>
<p translate="noData"></p>
</td>
</tr>
<tr ng-repeat="challenge in dashboardInfo.challenges" class="challenge-item {{challenge.$awardLowercase}} challenge-{{challenge.challengeId}}">
<td>
<div class="col-sm-4 challenge-name-col">
<a href="" target="_blank">
<i class="challenge-type" title="Public Challenge"></i>
<a href="#/challenge-detail/{{challenge.$asciiChallengeName}}-{{challenge.challengeId}}-id" target="_blank">
{{challenge.challengeName}}
</a>
<span class="note">12 day(s) left</span>
<span class="note" translate="{{challenge.$daysLeftTitle}}" />
</div>
<div class="col-sm-2 current-phase-col">
<span class="challenge-status idea">{{'idea' | translate}}</span>
<span class="note">0 day(s) left to submission</span>
<span class="challenge-status {{challenge.$currentPhaseLowerCase}}"
translate="{{challenge.$currentPhaseTitle}}" />
<span class="note" translate="{{challenge.$currentPhaseDescTitle}}" />
</div>
<div class="col-sm-2 submission-col">
<a ng-click="toggleSubmissions(challenge)" ng-if="challenge.submissions.length">{{challenge.submissions.length}}
<i class="fa fa-caret-down" ng-class="{'fa-caret-up': challenge.$toggle.isToggleSubmissions()}"></i></a>
<i class="fa fa-caret-down"></i></a>
<span ng-if="!challenge.submissions.length">-</span>
</div>
<div class="col-sm-2 score-col">
<a ng-click="toggleCriteria(challenge)" ng-if="challenge.$totalPoints > 0">{{challenge.$totalPoints}}
<i class="fa fa-caret-down" ng-class="{'fa-caret-up': challenge.$toggle.isToggleCriteria()}"></i></a>
<span ng-if="challenge.$totalPoints == 0">-</span>
<a ng-click="toggleCriteria(challenge)" ng-if="challenge.$hasSomeScore">{{challenge.$totalPoints}}
<i class="fa fa-caret-down"></i></a>
<span ng-if="!challenge.$hasSomeScore">-</span>
</div>
<div class="col-sm-1 prize-col">
{{challenge.$awardPrizeTitle}}
Expand All @@ -77,8 +81,8 @@ <h3 translate="myProfile"></h3>
<div class="col-sm-1 prize-col">
<span ng-if="challenge.rank" class="winner"></span>
</div>
<div class="challenge-toggle-criteria-{{challenge.challengeId}}"></div>
<div class="challenge-toggle-submissions-{{challenge.challengeId}}"></div>
<div class="challenge-toggle-criteria"></div>
<div class="challenge-toggle-submissions"></div>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,38 @@ techlooper.controller('jobseekerDashboardController', function ($scope, apiServi
});

$scope.toggleSubmissions = function (challenge) {
$("[class^='challenge-toggle-']").html("");

if (challenge.$toggle.isToggleSubmissions()) {
return challenge.$toggle.reset();
var challengeItem = $('.challenge-' + challenge.challengeId);
if(challengeItem.find('.fa-caret-down').hasClass('fa-caret-up')){
challengeItem.find('.challenge-toggle-submissions').html("");
challengeItem.find('.fa-caret-down').removeClass('fa-caret-up');
}else{
$("[class^='challenge-toggle-']").html("");
$('.my-challenge-list').find('.fa-caret-down').removeClass('fa-caret-up');

$scope.$challenge = challenge;
var html = "<jobseeker-submissions></jobseeker-submissions>";
var compiled = $compile(html)($scope);
challengeItem.find('.challenge-toggle-submissions').html(compiled);
challengeItem.find('.fa-caret-down').addClass('fa-caret-up');
}

challenge.$toggle.toggleSubmissions();
$scope.$challenge = challenge;
var html = "<jobseeker-submissions></jobseeker-submissions>";
var compiled = $compile(html)($scope);
$(".challenge-toggle-submissions-" + challenge.challengeId).html(compiled);
};

$scope.toggleCriteria = function (challenge) {
$("[class^='challenge-toggle-']").html("");

if (challenge.$toggle.isToggleCriteria()) {
return challenge.$toggle.reset();
var challengeItem = $('.challenge-' + challenge.challengeId);
if(challengeItem.find('.fa-caret-down').hasClass('fa-caret-up')){
challengeItem.find('.challenge-toggle-criteria').html("");
challengeItem.find('.fa-caret-down').removeClass('fa-caret-up');
}else{
$("[class^='challenge-toggle-']").html("");
$('.my-challenge-list').find('.fa-caret-down').removeClass('fa-caret-up');

$scope.$challenge = challenge;
var html = "<jobseeker-criteria></jobseeker-criteria>";
var compiled = $compile(html)($scope);
challengeItem.find('.challenge-toggle-criteria').html(compiled);
challengeItem.find('.fa-caret-down').addClass('fa-caret-up');
}

challenge.$toggle.toggleCriteria();
$scope.$challenge = challenge;
var html = "<jobseeker-criteria></jobseeker-criteria>";
var compiled = $compile(html)($scope);
$(".challenge-toggle-criteria-" + challenge.challengeId).html(compiled);
};

//challengeId: 1449129241321
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<tr>
<th translate="descriptionCol"></th>
<th translate="submissionLink"></th>
<th translate="date"></th>
<th translate="phase"></th>
<th translate="date"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="submission in $challenge.submissions">
<td>{{submission.submissionDescription}}</td>
<td><a href="{{submission.$submissionURL}}" target="_blank">{{submission.$submissionURL}}</a></td>
<td>{{submission.submissionDateTime}}</td>
<td>{{submission.$phaseTitle}}</td>
<td>{{submission.submissionDateTime}}</td>
</tr>
</table>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ <h1><a ng-href="#/{{state('home-url')}}"> <img src="images/logo-small.svg" alt="
<a href="#/hiring" translate="business" class="homepage-link"></a>
<p>{{$root.userInfo.name}}</p>
<div class="user-avatar" ng-show="$root.userInfo">
<img ng-src="{{$root.userInfo.profileImageUrl}}" alt="">
<img ng-src="{{$root.userInfo.profileImageUrl}}" alt="" ng-show="$root.userInfo.profileImageUrl.length">
<img src="images/no-avatar.png" alt="" ng-show="!$root.userInfo.profileImageUrl.length"/>
</div>
<a ng-show="!$root.userInfo" href="#/user-type" translate="signIn"></a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ <h1><a ng-href="#/{{state('home-url')}}"> <img src="images/logo-small.svg" alt="
<li ng-class="{ here: isActive('/challenges') }" ng-click="hideMenu()">
<a href="#/challenges" translate="codingChallenges" class="challenges"></a>
</li>
<!--<li ng-class="{ here: isActive('/freelancer/projects') }" ng-click="hideMenu()">-->
<!--<a href="#/freelancer/projects" translate="freelancer" class="freelancer"></a>-->
<!--</li>-->
<li ng-if="!$root.userInfo" ng-class="{ here: isActive('/freelancer/projects') }" ng-click="hideMenu()">
<a href="#/freelancer/projects" translate="freelancer" class="freelancer"></a>
</li>
<li ng-class="{ here: isActive('/pie-chart') }" ng-click="hideMenu()">
<a href="#/pie-chart" translate="subMenuAnalytics" class="analytics"></a>
</li>
Expand Down
8 changes: 6 additions & 2 deletions src/main/webapp/assets/modules/translation/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@
"delete": "Delete",
"registrationDate": "Registration Date",
"score": "Score",
"scoreLabel": "Score",
"reject": "Reject",
"pageNotFound": "This page does not exist.",
"disqualifyConfirmation": "Are you sure to disqualify this contestant?",
Expand Down Expand Up @@ -837,7 +838,7 @@
"submissionsReviewTip": "Review",
"announceWinnerToAllContestants": "Announce winners to all contestants",
"announceWinner": "Announce winners",
"daysLeft": "<strong>{{days}}</strong> day(s) left",
"daysLeft": "<strong>{{days}} day(s)</strong> left",
"qualifyToNextPhaseConfirm": "Select the phase this contestant is qualified to:",
"cannotQualifyNextPhase": "The <strong>{{nextPhase}}</strong> phase is not open for qualifications till by the end of <strong>{{endDatePhase}}</strong>.",
"gotIt": "Got it",
Expand Down Expand Up @@ -902,5 +903,8 @@
"submission": "Submission",
"challenge": "Challenge",
"phase": "Phase",
"showWinnerBoard": "Show Winner Board"
"showWinnerBoard": "Show Winner Board",
"finishedOn": "<strong>FINISHED</strong> on {{date}}",
"inPhase": "in <strong>{{phase}}</strong>",
"daysLeftToSubmit": "<strong>{{days}} day(s)</strong> left to submit"
}
Loading

0 comments on commit b31e924

Please sign in to comment.