-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #422 from phuonghuynh/master
Update changes
- Loading branch information
Showing
57 changed files
with
20,991 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/techlooper/cron/DailyChallengeSummaryEmailSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.techlooper.cron; | ||
|
||
import com.techlooper.entity.ChallengeEntity; | ||
import com.techlooper.model.ChallengePhaseEnum; | ||
import com.techlooper.service.ChallengeService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Service | ||
public class DailyChallengeSummaryEmailSender { | ||
|
||
private final static Logger LOGGER = LoggerFactory.getLogger(DailyChallengeSummaryEmailSender.class); | ||
|
||
@Resource | ||
private ChallengeService challengeService; | ||
|
||
@Value("${jobAlert.enable}") | ||
private Boolean enableJobAlert; | ||
|
||
@Scheduled(cron = "${scheduled.cron.dailyChallengeSummary}") | ||
public void notifyRegistrantAboutChallengeTimeline() throws Exception { | ||
if (enableJobAlert) { | ||
List<ChallengePhaseEnum> challengePhases = Arrays.asList(ChallengePhaseEnum.REGISTRATION, ChallengePhaseEnum.IN_PROGRESS); | ||
|
||
for (ChallengePhaseEnum challengePhase : challengePhases) { | ||
List<ChallengeEntity> challengeEntities = challengeService.listChallengesByPhase(challengePhase); | ||
|
||
for (ChallengeEntity challengeEntity : challengeEntities) { | ||
try { | ||
challengeService.sendDailySummaryEmailToChallengeOwner(challengeEntity); | ||
} catch (Exception ex) { | ||
LOGGER.error(ex.getMessage(), ex); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.