<commit_before>#!/bin/env node

'use strict';

var agent = require('superagent');
var program = require('commander');
var semver = require('semver');

var name, version;

program
    .version(require('./package.json').version)
    .arguments('<name> <version>')
    .action(function (name_, version_) {
        name = name_;
        version = version_;
    })
    .parse(process.argv);

// TODO shouldn't be needed, probably a bug in commander
if (!name) program.missingArgument('name');

if (!semver.valid(version)) {
    console.error('invalid version number: ' + version);
    process.exit(1);
}

var npmURL = 'https://skimdb.npmjs.com/registry/_design/app/_view/dependentVersions?startkey=%5B%22' + name + '%22%5D&endkey=%5B%22' + name + '!%22%5D&reduce=false';
agent.get(npmURL)
    .set('Accept', 'application/json')
    .end(function (error, response) {
        if (error) {
            throw error;
        }
        var packages = response.body.rows.filter(function (pack) {
            return semver.satisfies(version, pack.key[1]);
        }).map(function (pack) {
            return pack.id;// + '\t' + pack.key[1];
        });
        if (packages.length) {
            console.log(packages.join('\n'));
        }
    });<commit_msg>fix couchDB query<commit_after>#!/bin/env node

'use strict';

var agent = require('superagent');
var program = require('commander');
var semver = require('semver');

var name, version;

program
    .version(require('./package.json').version)
    .arguments('<name> <version>')
    .action(function (name_, version_) {
        name = name_;
        version = version_;
    })
    .parse(process.argv);

// TODO shouldn't be needed, probably a bug in commander
if (!name) program.missingArgument('name');

if (!semver.valid(version)) {
    console.error('invalid version number: ' + version);
    process.exit(1);
}

var encodedName = encodeURIComponent(name);
var npmURL = 'https://skimdb.npmjs.com/registry/_design/app/_view/dependentVersions?startkey=%5B%22' + encodedName + '%22%5D&endkey=%5B%22' + encodedName + '%22%2C%7B%7D%5D&reduce=false';
agent.get(npmURL)
    .set('Accept', 'application/json')
    .end(function (error, response) {
        if (error) {
            throw error;
        }
        var packages = response.body.rows.filter(function (pack) {
            return semver.satisfies(version, pack.key[1]);
        }).map(function (pack) {
            return pack.id;
        });
        if (packages.length) {
            console.log(packages.join('\n'));
        }
    });
{'fraction_non_alphanumeric': 0.1690307328605201, 'fraction_numerical': 0.01260835303388495, 'mean_word_length': 2.97339593114241, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '2587820', 'n_tokens_mistral': 814, 'n_tokens_neox': 799, 'n_words': 163}