<commit_before>const $1 = require('./getHRChallengesForHRSubDomain');
const $2 = require('./createGHIssueForHRChallenge');

module.exports = {
    createGHIssuesForHRSubDomain(password, hrSubDomain, label) {
        return $1.getHRChallengesForHRSubDomain(hrSubDomain)
                 .then(hrChallenges =>
                     Promise.all(hrChallenges.map(hrChallenge =>
                         $2.createGHIssueForHRChallenge(password, hrChallenge, label)
                     ))
                 )
                 .then(console.info.bind(console))
                 .catch(console.error.bind(console));
    }
};

module.exports.createGHIssuesForHRSubDomain(
    '4d99bb8071d4ad297ac716c1fea821615b422347',
    'https://www.hackerrank.com/domains/python/py-introduction',
    {domain: 'Python', subDomain: 'Introduction'}
);<commit_msg>resolve #2: Implement automated challenge issue creator.<commit_after>const $1 = require('./getHRChallengesForHRSubDomain');
const $2 = require('./createGHIssueForHRChallenge');

function delay(ms) {
    return () => new Promise(resolve => {
        setTimeout(resolve, ms);
    });
}

module.exports = {
    createGHIssuesForHRSubDomain(password, hrSubDomain, label) {
        return $1.getHRChallengesForHRSubDomain(hrSubDomain)
                 .then(hrChallenges =>
                     hrChallenges.reduce(
                         (chain, hrChallenge) => chain.then(delay(.5E3)).then(() =>
                             $2.createGHIssueForHRChallenge(password, hrChallenge, label)
                         ),
                         Promise.resolve()
                     )
                 )
                 .then(response => {
                     console.info(response.entity);
                 })
                 .catch(response => {
                     console.error(response.status);
                 });
    }
};

module.exports.createGHIssuesForHRSubDomain(
    '4d99bb8071d4ad297ac716c1fea821615b422347',
    'https://www.hackerrank.com/domains/python/py-collections',
    {domain: 'Python', subDomain: 'Collections'}
);
{'fraction_non_alphanumeric': 0.1189215214251324, 'fraction_numerical': 0.031295137217140105, 'mean_word_length': 2.1154422788605696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '7653686', 'n_tokens_mistral': 655, 'n_tokens_neox': 584, 'n_words': 71}