services/watch.js
function processWatches(items) {
  // queue up matches
  // { "member" : { "uri" : [ "match", "match" ] } }
  var toSend = {};
  GLOBAL.svc.indexer.retrieveWatches({}, function(err, res) {
    if (res.hits) {
      var watches = _.pluck(res.hits.hits, '_source');
      // for each hit
      items.forEach(function(item) {
        var matches = watchLib.matches(item, watches);
        if (matches.length) {
          matches.forEach(function(match) {
            toSend[match.member] = toSend[match.member] || {};
            toSend[match.member][item.uri] = toSend[match.member][item.uri] || [];
            toSend[match.member][item.uri].push(match.match);
          });
        }
      });
      send(toSend);
    }
  });
}
function processWatches(items) {
  // queue up matches
  // { "member" : { "uri" : [ "match", "match" ] } }
  var toSend = {};
  GLOBAL.svc.indexer.retrieveWatches({}, function(err, res) {
    if (res.hits) {
      var watches = _.pluck(res.hits.hits, '_source');
      // for each hit
      items.forEach(function(item) {
        var matches = watchLib.matches(item, watches);
        if (matches.length) {
          matches.forEach(function(match) {
            toSend[match.member] = toSend[match.member] || {};
            toSend[match.member][item.uri] = toSend[match.member][item.uri] || [];
            toSend[match.member][item.uri].push(match.match);
          });
        }
      });
      send(toSend);
    }
  });
}
function processWatches ( items ) { // queue up matches // { "member" : { "uri" : [ "match", "match" ] } } var toSend = { } ; GLOBAL . svc . indexer . retrieveWatches ( { } , function ( err , res ) { if ( res . hits ) { var watches = _ . pluck ( res . hits . hits , '_source' ) ; // for each hit items . forEach ( function ( item ) { var matches = watchLib . matches ( item , watches ) ; if ( matches . length ) { matches . forEach ( function ( match ) { toSend [ match . member ] = toSend [ match . member ] || { } ; toSend [ match . member ] [ item . uri ] = toSend [ match . member ] [ item . uri ] || [ ] ; toSend [ match . member ] [ item . uri ] . push ( match . match ) ; } ) ; } } ) ; send ( toSend ) ; } } ) ; }
process any watches in the last time period
process any watches in the last time period