<commit_before>package mingzuozhibi.config;

import mingzuozhibi.service.AmazonNewDiscSpider;
import mingzuozhibi.service.AmazonScheduler;
import mingzuozhibi.service.SakuraSpeedSpider;
import mingzuozhibi.service.ScheduleMission;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class AutoRunConfig {

    public static final Logger LOGGER = LoggerFactory.getLogger(AutoRunConfig.class);

    @Autowired
    private AmazonScheduler scheduler;

    @Autowired
    private ScheduleMission scheduleMission;

    @Autowired
    private SakuraSpeedSpider sakuraSpeedSpider;

    @Autowired
    private AmazonNewDiscSpider amazonNewDiscSpider;

    @Value("${IS_JAPAN_SERVER}")
    private boolean isJapanServer;

    @Value("${JAPAN_SERVER_IP}")
    private String japanServerIp;

    /**
     * call by MzzbServerApplication
     */
    public void runOnStartupServer() {
        if (!isJapanServer) {
//            sakuraSpeedSpider.fetch(true);
            scheduleMission.removeExpiredDiscsFromList();
            scheduleMission.removeExpiredAutoLoginData();
            scheduleMission.recordDiscsRankAndComputePt();
        }
    }

    @Scheduled(cron = "0 2 * * * ?")
    public void runOnEveryHour() {
        if (!isJapanServer) {
            LOGGER.info("每小时任务开始");
            scheduleMission.removeExpiredDiscsFromList();
            scheduleMission.removeExpiredAutoLoginData();
            scheduleMission.recordDiscsRankAndComputePt();
            LOGGER.info("每小时任务完成");
        }
    }

    @Scheduled(cron = "0 12 4 * * ?")
    public void runOnEveryDate() {
        if (!isJapanServer) {
//            sakuraSpeedSpider.fetch(true);
            scheduleMission.updateDiscsTitleAndRelease();
        }
    }

//    @Scheduled(cron = "10 0/2 * * * ?")
//    public void fetchSakuraSpeedData() {
//        if (!isJapanServer) {
//            sakuraSpeedSpider.fetch(false);
//        }
//    }

    @Scheduled(cron = "10 1/2 * * * ?")
    public void fetchAmazonRankData() {
        if (!isJapanServer) {
            scheduler.fetchData();
        }
    }

    @Scheduled(cron = "0 0 5/6 * * ?")
    public void fetchNewDiscData() {
        if (isJapanServer) {
            amazonNewDiscSpider.fetch();
        }
    }

    @Scheduled(cron = "0 0,20 0/6 * * ?")
    public void fetchNewDiscDataFromJapan() {
        if (!isJapanServer) {
            amazonNewDiscSpider.fetchFromJapan(japanServerIp);
        }
    }

}<commit_msg>feat(new-disc): Add request fetch api<commit_after>package mingzuozhibi.config;

import mingzuozhibi.service.AmazonNewDiscSpider;
import mingzuozhibi.service.AmazonScheduler;
import mingzuozhibi.service.SakuraSpeedSpider;
import mingzuozhibi.service.ScheduleMission;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Service
@RestController
public class AutoRunConfig {

    public static final Logger LOGGER = LoggerFactory.getLogger(AutoRunConfig.class);

    @Autowired
    private AmazonScheduler scheduler;

    @Autowired
    private ScheduleMission scheduleMission;

    @Autowired
    private SakuraSpeedSpider sakuraSpeedSpider;

    @Autowired
    private AmazonNewDiscSpider amazonNewDiscSpider;

    @Value("${IS_JAPAN_SERVER}")
    private boolean isJapanServer;

    @Value("${JAPAN_SERVER_IP}")
    private String japanServerIp;

    /**
     * call by MzzbServerApplication
     */
    public void runOnStartupServer() {
        if (!isJapanServer) {
//            sakuraSpeedSpider.fetch(true);
            scheduleMission.removeExpiredDiscsFromList();
            scheduleMission.removeExpiredAutoLoginData();
            scheduleMission.recordDiscsRankAndComputePt();
        }
    }

    @Scheduled(cron = "0 2 * * * ?")
    public void runOnEveryHour() {
        if (!isJapanServer) {
            LOGGER.info("每小时任务开始");
            scheduleMission.removeExpiredDiscsFromList();
            scheduleMission.removeExpiredAutoLoginData();
            scheduleMission.recordDiscsRankAndComputePt();
            LOGGER.info("每小时任务完成");
        }
    }

    @Scheduled(cron = "0 12 4 * * ?")
    public void runOnEveryDate() {
        if (!isJapanServer) {
//            sakuraSpeedSpider.fetch(true);
            scheduleMission.updateDiscsTitleAndRelease();
        }
    }

//    @Scheduled(cron = "10 0/2 * * * ?")
//    public void fetchSakuraSpeedData() {
//        if (!isJapanServer) {
//            sakuraSpeedSpider.fetch(false);
//        }
//    }

    @Scheduled(cron = "10 1/2 * * * ?")
    public void fetchAmazonRankData() {
        if (!isJapanServer) {
            scheduler.fetchData();
        }
    }

    @GetMapping("/requestNewDiscs")
    public void fetchNewDiscsDataRequest() {
        if (isJapanServer) {
            amazonNewDiscSpider.fetch();
        } else {
            amazonNewDiscSpider.fetchFromJapan(japanServerIp);
        }
    }

    @Scheduled(cron = "0 0 5/6 * * ?")
    public void fetchNewDiscData() {
        if (isJapanServer) {
            amazonNewDiscSpider.fetch();
        }
    }

    @Scheduled(cron = "0 0,20 0/6 * * ?")
    public void fetchNewDiscDataFromJapan() {
        if (!isJapanServer) {
            amazonNewDiscSpider.fetchFromJapan(japanServerIp);
        }
    }

}
{'fraction_non_alphanumeric': 0.1065771349862259, 'fraction_numerical': 0.008953168044077135, 'mean_word_length': 2.801701570680628, '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': '3829090', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1786, 'n_words': 278}