text: // Generated by IcedCoffeeScript 1.8.0-c
  (function() {
    var dd, emit, _;
  
    _ = require('underscore');
  
    dd = {
      views: {
        failures_by_retry_date: {
          map: function(doc) {
            var entry, nextAttemptTime, now, _i, _len, _ref, _ref1, _ref2;
            now = +new Date();
            nextAttemptTime = 1e+100;
            _ref = doc.audit || [];
            for (_i = 0, _len = _ref.length; _i < _len; _i++) {
              entry = _ref[_i];
              if (((_ref1 = entry.attempts) != null ? _ref1[0] : void 0) < nextAttemptTime) {
                nextAttemptTime = (_ref2 = entry.attempts) != null ? _ref2[0] : void 0;
              }
            }
            if (nextAttemptTime < 1e+100) {
              return emit(nextAttemptTime);
            }
          }
        },
        audit_by_timestamp: {
          map: function(doc) {
            var entry, out, typ, _i, _len, _ref, _results;
            _ref = doc.audit;
            _results = [];
            for (_i = 0, _len = _ref.length; _i < _len; _i++) {
              entry = _ref[_i];
              typ = doc._id.indexOf('team_') === 0 ? 'team' : 'user';
              out = {
                _id: doc._id,
                name: doc.name,
                entry: entry,
                type: typ
              };
              _results.push(emit(entry.dt, out));
            }
            return _results;
          }
        }
      },
      lists: {
        get_values: function(header, req) {
          var out, row, val;
          out = [];
          while ((row = getRow())) {
            val = row.value;
            out.push(val);
          }
          return JSON.stringify(out);
        }
      },
      rewrites: [
        {
          from: "/audit",
          to: "/_list/get_values/audit_by_timestamp",
          query: {}
        }
      ],
      shows: {},
      updates: {}
    };
  
    if (typeof emit === 'undefined') {
      dd.emitted = [];
      emit = function(k, v) {
        return dd.emitted.push([k, v]);
      };
    }
  
    module.exports = dd;
  
  }).call(this);
  