<commit_before>import requests
from tasks.models import Tasks
from .base import library
from .utils import logger


@library.register('travis_ci')
def travis_ci_service(data):
    """Create task from data dict"""
    try:
        assert Tasks.find({
            'service.name': 'travis_ci',
            'service.job_id': data['service']['job_id'],
        }).count() <= 1

        job = requests.get(
            'https://api.travis-ci.org/jobs/{}'.format(
                data['service']['job_id'],
            ),
        ).json()

        repo = requests.get(
            'https://api.travis-ci.org/repos/{}'.format(
                job['repository_id'],
            ),
        ).json()

        # TODO: add pull request support
        assert data['project'] == repo['slug']

        if data['service'].get('pull_request_id'):
            data['pull_request_id'] = data['service']['pull_request_id']

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Travis-ci service fail: {}'.format(e))<commit_msg>In real world pull_request_id is string =(<commit_after>import requests
from tasks.models import Tasks
from .base import library
from .utils import logger


@library.register('travis_ci')
def travis_ci_service(data):
    """Create task from data dict"""
    try:
        assert Tasks.find({
            'service.name': 'travis_ci',
            'service.job_id': data['service']['job_id'],
        }).count() <= 1

        job = requests.get(
            'https://api.travis-ci.org/jobs/{}'.format(
                data['service']['job_id'],
            ),
        ).json()

        repo = requests.get(
            'https://api.travis-ci.org/repos/{}'.format(
                job['repository_id'],
            ),
        ).json()

        # TODO: add pull request support
        assert data['project'] == repo['slug']

        if data['service'].get('pull_request_id'):
            pull_request = data['service']['pull_request_id']
            if pull_request != 'false':
                data['pull_request_id'] = int(
                    data['service']['pull_request_id'],
                )

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Travis-ci service fail: {}'.format(e))
{'fraction_non_alphanumeric': 0.15123586091328026, 'fraction_numerical': 0.0008378718056137411, 'mean_word_length': 2.069408740359897, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '731089', 'n_tokens_mistral': 696, 'n_tokens_neox': 679, 'n_words': 147}