<commit_before>package org.literacyapp.tasks;

import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.literacyapp.dao.ContributorDao;
import org.literacyapp.model.Contributor;
import org.literacyapp.model.enums.Environment;
import org.literacyapp.util.MailChimpApiHelper;
import org.literacyapp.web.context.EnvironmentContextLoaderListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class MailChimpScheduler {
    
    private Logger logger = Logger.getLogger(getClass());

    @Autowired
    private ContributorDao contributorDao;
    
    @Scheduled(cron="00 10 * * * *") // 10 past every hour
    public synchronized void executeImport() {
        logger.info("executeImport");
        
        if (EnvironmentContextLoaderListener.env != Environment.PROD) {
            return;
        }
        
        List<Contributor> contributors = contributorDao.readAll();
        logger.info("contributors.size(): " + contributors.size());
        for (Contributor contributor : contributors) {
            // Check if contributor is already subscribed to the mailing list
            String memberInfo = MailChimpApiHelper.getMemberInfo(contributor.getEmail());
            logger.info("memberInfo: " + memberInfo);
            if (StringUtils.isBlank(memberInfo)) {
                MailChimpApiHelper.subscribeMember(contributor);
            }
        }
        
        logger.info("executeImport complete");
    }
    
    /**
     * Sync data registered for existing subscribers.
     */
    @Scheduled(cron="00 20 * * * *") // 20 past every hour
    public synchronized void executeDataSync() {
        logger.info("executeDataSync");<commit_msg>Fixed broken MailChimp import<commit_after>package org.literacyapp.tasks;

import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.literacyapp.dao.ContributorDao;
import org.literacyapp.model.Contributor;
import org.literacyapp.model.enums.Environment;
import org.literacyapp.util.MailChimpApiHelper;
import org.literacyapp.web.context.EnvironmentContextLoaderListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class MailChimpScheduler {
    
    private Logger logger = Logger.getLogger(getClass());

    @Autowired
    private ContributorDao contributorDao;
    
    @Scheduled(cron="00 10 * * * *") // 10 past every hour
    public synchronized void executeImport() {
        logger.info("executeImport");
        
        if (EnvironmentContextLoaderListener.env != Environment.PROD) {
            return;
        }
        
        List<Contributor> contributors = contributorDao.readAll();
        logger.info("contributors.size(): " + contributors.size());
        for (Contributor contributor : contributors) {
            // Check if contributor is already subscribed to the mailing list
            String memberInfo = MailChimpApiHelper.getMemberInfo(contributor.getEmail());
            if (StringUtils.isBlank(memberInfo)) {
                MailChimpApiHelper.subscribeMember(contributor);
            }
        }
        
        logger.info("executeImport complete");
    }
    
    /**
     * Sync data registered for existing subscribers.
     */
    @Scheduled(cron="00 20 * * * *") // 20 past every hour
    public synchronized void executeDataSync() {
        logger.info("executeDataSync");
{'fraction_non_alphanumeric': 0.0994535519125683, 'fraction_numerical': 0.007103825136612022, 'mean_word_length': 3.184, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3953942', 'n_tokens_mistral': 996, 'n_tokens_neox': 969, 'n_words': 194}