<commit_before>package com.nincraft.ninbot.components.ac.turnips;

import com.nincraft.ninbot.components.ac.VillagerRepository;
import com.nincraft.ninbot.components.common.Schedulable;
import lombok.extern.log4j.Log4j2;
import lombok.val;
import net.dv8tion.jda.api.sharding.ShardManager;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

@Log4j2
@Component
public class TurnipPricesScheduler implements Schedulable {

    private TurnipPricesManager turnipPricesManager;
    private VillagerRepository villagerRepository;
    private TurnipPricesRepository turnipPricesRepository;

    public TurnipPricesScheduler(TurnipPricesManager turnipPricesManager, VillagerRepository villagerRepository,
            TurnipPricesRepository turnipPricesRepository) {
        this.turnipPricesManager = turnipPricesManager;
        this.villagerRepository = villagerRepository;
        this.turnipPricesRepository = turnipPricesRepository;
    }


    @Override
    public void scheduleAll(ShardManager shardManager) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.DATE, 1);
        while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
            calendar.add(Calendar.DATE, 1);
        }
        Date nextSunday = calendar.getTime();
        log.trace("Scheduling turnips price reset for {}", nextSunday);
        new Timer().scheduleAtFixedRate(new TurnipTasks(), nextSunday, TimeUnit.DAYS.toMillis(7));
    }


    private class TurnipTasks extends TimerTask {
        @Override
        public void run() {
            log.trace("Running turnips price reset");
            TurnipPrices turnipPrices = turnipPricesRepository.findAll().get(0);
            if (turnipPrices.getCreated().getDayOfMonth() != LocalDate.now().getDayOfMonth()) {
                val villagerList = villagerRepository.findAll();
                log.trace("Resetting turnip counts for {} villagers", villagerList.size());
                villagerList.forEach(villager -> {
                    villager.setTurnipsOwned(0);
                    villagerRepository.save(villager);
                });
                turnipPricesManager.generateNewWeek();
            }
        }
    }
}
<commit_msg>Universal Basic Income (of turnips)<commit_after>package com.nincraft.ninbot.components.ac.turnips;

import com.nincraft.ninbot.components.ac.VillagerRepository;
import com.nincraft.ninbot.components.common.Schedulable;
import lombok.extern.log4j.Log4j2;
import lombok.val;
import net.dv8tion.jda.api.sharding.ShardManager;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

@Log4j2
@Component
public class TurnipPricesScheduler implements Schedulable {

    private TurnipPricesManager turnipPricesManager;
    private VillagerRepository villagerRepository;
    private TurnipPricesRepository turnipPricesRepository;

    public TurnipPricesScheduler(TurnipPricesManager turnipPricesManager, VillagerRepository villagerRepository,
            TurnipPricesRepository turnipPricesRepository) {
        this.turnipPricesManager = turnipPricesManager;
        this.villagerRepository = villagerRepository;
        this.turnipPricesRepository = turnipPricesRepository;
    }


    @Override
    public void scheduleAll(ShardManager shardManager) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.DATE, 1);
        while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
            calendar.add(Calendar.DATE, 1);
        }
        Date nextSunday = calendar.getTime();
        log.trace("Scheduling turnips price reset for {}", nextSunday);
        new Timer().scheduleAtFixedRate(new TurnipTasks(), nextSunday, TimeUnit.DAYS.toMillis(7));
    }


    private class TurnipTasks extends TimerTask {
        @Override
        public void run() {
            log.trace("Running turnips price reset");
            TurnipPrices turnipPrices = turnipPricesRepository.findAll().get(0);
            if (turnipPrices.getCreated().getDayOfMonth() != LocalDate.now().getDayOfMonth()) {
                val villagerList = villagerRepository.findAll();
                log.trace("Resetting turnip counts for {} villagers", villagerList.size());
                villagerList.forEach(villager -> {
                    villager.setTurnipsOwned(10);
                    villagerRepository.save(villager);
                });
                turnipPricesManager.generateNewWeek();
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.09141445336627547, 'fraction_numerical': 0.004735433395099856, 'mean_word_length': 3.2353966870095903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2408513', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1338, 'n_words': 240}