<commit_before>package com.github.neunkasulle.chronocommand.control;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;

/**
 * Created by Dav on 26.01.2016.
 * Name can be changed everytime
 */
public class SchedulerHandler {
    private static final Logger LOGGER = LoggerFactory.getLogger(SchedulerHandler.class);

    private static final SchedulerHandler ourInstance = new SchedulerHandler();

    private static Scheduler sched;

    private SchedulerHandler() {

    }

    public static SchedulerHandler getInstance() {
        return ourInstance;
    }



    private static void intantiateSched() throws SchedulerException {
        SchedulerFactory schedFact = new StdSchedulerFactory();
        sched = schedFact.getScheduler();
    }

    /**
     * schedules all jobs with the triggers
     */
    public static void scheduleAll() {
        try {
            intantiateSched();
        } catch (SchedulerException e) {
            LOGGER.error("Failure in instantiating scheduler", e);
        }

        JobDetail weeklyReminderJob = newJob(WeeklyMailJob.class)
                .withIdentity("weeklyReminderJob", "weeklyReminder") //name, group
                .build();

        JobDetail monthlyReminderJob = newJob(MonthlyReminder.class)
                .withIdentity("monthlyReminderJob", "monthlyReminder")
                .build();

        Trigger lastDayOfMonth = newTrigger() //fires at 12pm every last day every month
                .withIdentity("lastDayTrigger", "monthlyreminder")
                .withSchedule(cronSchedule("0 0 12 L * ?"))
                .startNow()
                .build();

        Trigger weeklyTrigger = newTrigger() //every week at 12pm in every month
                .withIdentity("weeklyTrigger", "weeklyReminder")
                .withSchedule(cronSchedule("0 0 12 ? * L"))
                .startNow()
                .build();

        //trigger for tesst purpose
        JobDetail dailyReminderJob = newJob(WeeklyMailJob.class)
                .withIdentity("dailyTrigger", "testGroup") //name, group
                .build();
        Trigger dailyTrigger = newTrigger()
                .withIdentity("dailyTrigger", "testGroup")
                .withSchedule(cronSchedule("0 0 12 * * ?"))
                .startNow()
                .build();

        try {
            sched.start();
            // Tell quartz to schedule a job with a trigger
            sched.scheduleJob(monthlyReminderJob, lastDayOfMonth);<commit_msg>set weekly trigger to sunday and not saturday<commit_after>package com.github.neunkasulle.chronocommand.control;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;

/**
 * Created by Dav on 26.01.2016.
 * Name can be changed everytime
 */
public class SchedulerHandler {
    private static final Logger LOGGER = LoggerFactory.getLogger(SchedulerHandler.class);

    private static final SchedulerHandler ourInstance = new SchedulerHandler();

    private static Scheduler sched;

    private SchedulerHandler() {

    }

    public static SchedulerHandler getInstance() {
        return ourInstance;
    }



    private static void intantiateSched() throws SchedulerException {
        SchedulerFactory schedFact = new StdSchedulerFactory();
        sched = schedFact.getScheduler();
    }

    /**
     * schedules all jobs with the triggers
     */
    public static void scheduleAll() {
        try {
            intantiateSched();
        } catch (SchedulerException e) {
            LOGGER.error("Failure in instantiating scheduler", e);
        }

        JobDetail weeklyReminderJob = newJob(WeeklyMailJob.class)
                .withIdentity("weeklyReminderJob", "weeklyReminder") //name, group
                .build();

        JobDetail monthlyReminderJob = newJob(MonthlyReminder.class)
                .withIdentity("monthlyReminderJob", "monthlyReminder")
                .build();

        Trigger lastDayOfMonth = newTrigger() //fires at 12pm every last day every month
                .withIdentity("lastDayTrigger", "monthlyreminder")
                .withSchedule(cronSchedule("0 0 12 L * ?"))
                .startNow()
                .build();

        Trigger weeklyTrigger = newTrigger() //every week at 12pm in every month
                .withIdentity("weeklyTrigger", "weeklyReminder")
                .withSchedule(cronSchedule("0 0 12 ? * SUN"))
                .startNow()
                .build();

        //trigger for tesst purpose
        JobDetail dailyReminderJob = newJob(WeeklyMailJob.class)
                .withIdentity("dailyTrigger", "testGroup") //name, group
                .build();
        Trigger dailyTrigger = newTrigger()
                .withIdentity("dailyTrigger", "testGroup")
                .withSchedule(cronSchedule("0 0 12 * * ?"))
                .startNow()
                .build();

        try {
            sched.start();
            // Tell quartz to schedule a job with a trigger
            sched.scheduleJob(monthlyReminderJob, lastDayOfMonth);
{'fraction_non_alphanumeric': 0.09420821114369501, 'fraction_numerical': 0.009530791788856305, 'mean_word_length': 2.3315018315018317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4744381', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1389, 'n_words': 356}