<commit_before>
function Search()
{
}

Search.USER_URL = "https://codereview.chromium.org/account?limit={1}&q={2}";
Search.ISSUE_URL = "https://codereview.chromium.org/search?format=json&closed={1}&owner={2}&reviewer={3}&limit={4}&cursor={5}"

Search.findUsers = function(query, limit)
{
    var url = Search.USER_URL.assign(
        encodeURIComponent(Number(limit) || 10),
        encodeURIComponent(query));

    return loadText(url).then(function(text) {
        var users = [];
        text.split("\n").each(function(line) {
            if (!line.trim())
                return;
            var user = new User();
            user.parseDetail(line);
            users.push(user);
        });
        return users;
    });
};

Search.findIssues = function(query, limit)
{
    // 0 = Unknown, 1 = Closed, 2 = Not Closed.
    var closed = 0;
    if (query.hasOwnProperty('closed'))
        closed = query.closed ? 1 : 2;

    var url = Search.ISSUE_URL.assign(
        encodeURIComponent(closed),
        encodeURIComponent(query.owner || ""),
        encodeURIComponent(query.reviewer || ""),
        encodeURIComponent(Number(limit) || 10),
        encodeURIComponent(query.cursor || ""));

    return loadJSON(url).then(function(data) {
        var issues = data.results.map(function(issueData) {
            var issue = new Issue(issueData.issue);
            issue.parseData(issueData);
            return issue;
        });
        return new SearchResult(issues, data.cursor);
    });
}<commit_msg>Refactor default search result limit<commit_after>
function Search()
{
}

Search.USER_URL = "https://codereview.chromium.org/account?limit={1}&q={2}";
Search.ISSUE_URL = "https://codereview.chromium.org/search?format=json&closed={1}&owner={2}&reviewer={3}&limit={4}&cursor={5}";
Search.DEFAULT_LIMIT = 10;

Search.findUsers = function(query, limit)
{
    var url = Search.USER_URL.assign(
        encodeURIComponent(Number(limit) || Search.DEFAULT_LIMIT),
        encodeURIComponent(query));

    return loadText(url).then(function(text) {
        var users = [];
        text.split("\n").each(function(line) {
            if (!line.trim())
                return;
            var user = new User();
            user.parseDetail(line);
            users.push(user);
        });
        return users;
    });
};

Search.findIssues = function(query, limit)
{
    // 0 = Unknown, 1 = Closed, 2 = Not Closed.
    var closed = 0;
    if (query.hasOwnProperty('closed'))
        closed = query.closed ? 1 : 2;

    var url = Search.ISSUE_URL.assign(
        encodeURIComponent(closed),
        encodeURIComponent(query.owner || ""),
        encodeURIComponent(query.reviewer || ""),
        encodeURIComponent(Number(limit) || Search.DEFAULT_LIMIT),
        encodeURIComponent(query.cursor || ""));

    return loadJSON(url).then(function(data) {
        var issues = data.results.map(function(issueData) {
            var issue = new Issue(issueData.issue);
            issue.parseData(issueData);
            return issue;
        });
        return new SearchResult(issues, data.cursor);
    });
}
{'fraction_non_alphanumeric': 0.15156401160915833, 'fraction_numerical': 0.010319251854240567, 'mean_word_length': 2.6710059171597633, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3054694', 'n_tokens_mistral': 952, 'n_tokens_neox': 943, 'n_words': 158}