<commit_before>var couchapp = require('couchapp');
var path = require('path');

var ddoc = { _id:'_design/app' };

ddoc.validate_doc_update = function (newDoc, oldDoc, userCtx) {   
  if (newDoc._deleted === true && userCtx.roles.indexOf('_admin') === -1) {
    throw "Only admin can delete documents on this database.";
  } 
};

ddoc.filters = {
  unseen: function(doc, req) {
    var i;

    if(doc._deleted || !doc.server) {
      return false;
    }

    if(!doc.clientsSeen || !doc.clientsSeen.length) {
      return true;
    }

    if(!req.query || !req.query.client) {
      return true;
    }

    for(i in doc.clientsSeen) {
      if(doc.clientsSeen.hasOwnProperty(i) && doc.clientsSeen[i] == req.query.client) {
        return false;
      }
    }

    return true;
  }
};

module.exports = ddoc;<commit_msg>A view for debugging dupe or un-sync'd client names<commit_after>var couchapp = require('couchapp');
var path = require('path');

var ddoc = { _id:'_design/app' };

ddoc.validate_doc_update = function (newDoc, oldDoc, userCtx) {   
  if (newDoc._deleted === true && userCtx.roles.indexOf('_admin') === -1) {
    throw "Only admin can delete documents on this database.";
  } 
};

ddoc.filters = {
  unseen: function(doc, req) {
    var i;

    if(doc._deleted || !doc.server) {
      return false;
    }

    if(!doc.clientsSeen || !doc.clientsSeen.length) {
      return true;
    }

    if(!req.query || !req.query.client) {
      return true;
    }

    for(i in doc.clientsSeen) {
      if(doc.clientsSeen.hasOwnProperty(i) && doc.clientsSeen[i] == req.query.client) {
        return false;
      }
    }

    return true;
  }
};

ddoc.views = {};

ddoc.views.clientsSeenCount = {};
ddoc.views.clientsSeenCount.map = function(doc) {
  if(doc.clientsSeen) {
    emit('_total', null);

    doc.clientsSeen.forEach(function(client) {
      emit(client, null);
    });
  }
};
ddoc.views.clientsSeenCount.reduce = '_count';

module.exports = ddoc;
{'fraction_non_alphanumeric': 0.15826972010178117, 'fraction_numerical': 0.0010178117048346056, 'mean_word_length': 2.893069306930693, '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': '3462102', 'n_tokens_mistral': 719, 'n_tokens_neox': 714, 'n_words': 135}