<commit_before>var couch = require('./couch/couch.js');

var create = function (doc, callback) {
    var oneDay = 1000 * 60 * 60 * 24;
    var fiveDays = oneDay * 5;

    var invite = {
        circleId: doc.circleId,
        count: doc.count,
        expires: Date.now() + fiveDays, 
        type: "invite"
    };

    couch.docs.get(doc.circleId, function (err, circle) {
        if (err) {
            callback(err);
            return;
        }

        invite.circleName = circle.name;
        couch.db.insert(invite, function (err, successDoc) {
            if (err) {
                callback(err);
                return;
            }
            invite._id = successDoc.id;
            invite._rev = successDoc.rev;
            callback(null, invite);
        });
    });
};

var get = function (docId, callback) {
    couch.docs.get(docId, function (err, doc) {
        if (err) {
            callback(err);
            return;
        }

        if (doc.type !== "invite") {
            callback(null);
            return;
        }<commit_msg>Invite: Use more-random IDs<commit_after>var couch = require('./couch/couch.js');
var uuid = require('node-uuid');

var create = function (doc, callback) {
    var oneDay = 1000 * 60 * 60 * 24;
    var fiveDays = oneDay * 5;

    var inviteId = uuid.v4();
    var invite = {
        circleId: doc.circleId,
        count: doc.count,
        expires: Date.now() + fiveDays, 
        type: "invite"
    };

    couch.docs.get(doc.circleId, function (err, circle) {
        if (err) {
            callback(err);
            return;
        }

        invite.circleName = circle.name;
        couch.db.insert(invite, inviteId, function (err, successDoc) {
            if (err) {
                callback(err);
                return;
            }
            invite._id = successDoc.id;
            invite._rev = successDoc.rev;
            callback(null, invite);
        });
    });
};

var get = function (docId, callback) {
    couch.docs.get(docId, function (err, doc) {
        if (err) {
            callback(err);
            return;
        }

        if (doc.type !== "invite") {
            callback(null);
            return;
        }
{'fraction_non_alphanumeric': 0.13130395274875056, 'fraction_numerical': 0.010449795547478418, 'mean_word_length': 1.5194508009153318, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1743221', 'n_tokens_mistral': 695, 'n_tokens_neox': 666, 'n_words': 152}