<commit_before>/**
 * Based on: https://github.com/iriscouch/manage_couchdb/
 * License: Apache License 2.0
 **/
function(newDoc, oldDoc, userCtx, secObj) {
  var ddoc = this;

  secObj.admins = secObj.admins || {};
  secObj.admins.names = secObj.admins.names || [];
  secObj.admins.roles = secObj.admins.roles || [];

  var IS_DB_ADMIN = false;
  if(~ userCtx.roles.indexOf('_admin'))
    IS_DB_ADMIN = true;
  if(~ secObj.admins.names.indexOf(userCtx.name))
    IS_DB_ADMIN = true;
  for(var i = 0; i < userCtx.roles; i++)
    if(~ secObj.admins.roles.indexOf(userCtx.roles[i]))
      IS_DB_ADMIN = true;
  // check access.json's write_roles collection
  for(var i = 0; i < userCtx.roles; i++)
    if(~ ddoc.write_roles.indexOf(userCtx.roles[i]))
      IS_DB_ADMIN = true;

  if(ddoc.access && ddoc.access.read_only)
    if(IS_DB_ADMIN)
      log('Admin change on read-only db: ' + newDoc._id);<commit_msg>Make perms write_roles actually work<commit_after>/**
 * Based on: https://github.com/iriscouch/manage_couchdb/
 * License: Apache License 2.0
 **/
function(newDoc, oldDoc, userCtx, secObj) {
  var ddoc = this;

  secObj.admins = secObj.admins || {};
  secObj.admins.names = secObj.admins.names || [];
  secObj.admins.roles = secObj.admins.roles || [];

  var IS_DB_ADMIN = false;
  if(~ userCtx.roles.indexOf('_admin'))
    IS_DB_ADMIN = true;
  if(~ secObj.admins.names.indexOf(userCtx.name))
    IS_DB_ADMIN = true;
  for(var i = 0; i < userCtx.roles; i++)
    if(~ secObj.admins.roles.indexOf(userCtx.roles[i]))
      IS_DB_ADMIN = true;
  // check access.json's write_roles collection
  for(var i = 0; i < userCtx.roles.length; i++)
    if(~ ddoc.access.write_roles.indexOf(userCtx.roles[i]))
      IS_DB_ADMIN = true;

  if(ddoc.access && ddoc.access.read_only)
    if(IS_DB_ADMIN)
      log('Admin change on read-only db: ' + newDoc._id);
{'fraction_non_alphanumeric': 0.1586616297895305, 'fraction_numerical': 0.004317323259579061, 'mean_word_length': 3.577777777777778, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '2538760', 'n_tokens_mistral': 763, 'n_tokens_neox': 744, 'n_words': 133}