Skip to content

Instantly share code, notes, and snippets.

@josefsalyer
Created August 25, 2010 17:48
Show Gist options
  • Save josefsalyer/549957 to your computer and use it in GitHub Desktop.
Save josefsalyer/549957 to your computer and use it in GitHub Desktop.
m = function () {
var events = [this._id];
if (this.tags) {
this.tags.forEach( function (z) {
emit( z, {count:1, events: events} );
});
}
}
r = function (key, values) {
var total = 0;
events = [];
for (var i = 0; i < values.length; i++) {
total += values[i].count;
events = events.concat(events, values[i].events);
}
return {count:total, events:events};
}
return {count:total, events:events};
}
{{ "_id" : "5", "value" : { "count" : 1, "events" : [ 4 ] } }
{ "_id" : "abc", "value" : { "count" : 1, "events" : [ 8 ] } }
{ "_id" : "america", "value" : { "count" : 1, "events" : [ 9 ] } }
{ "_id" : "british", "value" : { "count" : 3, "events" : [ ] } }
{ "_id" : "business", "value" : { "count" : 1, "events" : [ 2 ] } }
{ "_id" : "comeback", "value" : { "count" : 1, "events" : [ 5 ] } }
{ "_id" : "early", "value" : { "count" : 1, "events" : [ 3 ] } }
{ "_id" : "edition", "value" : { "count" : 1, "events" : [ 4 ] } }
{ "_id" : "first", "value" : { "count" : 2, "events" : [ ] } }
{ "_id" : "good", "value" : { "count" : 1, "events" : [ 10 ] } }
{ "_id" : "invasion", "value" : { "count" : 3, "events" : [ ] } }
{ "_id" : "jay", "value" : { "count" : 3, "events" : [ ] } }
{ "_id" : "ksl", "value" : { "count" : 1, "events" : [ 4 ] } }
{ "_id" : "leno", "value" : { "count" : 3, "events" : [ ] } }
{ "_id" : "morning", "value" : { "count" : 2, "events" : [ ] } }
{ "_id" : "news", "value" : { "count" : 2, "events" : [ ] } }
{ "_id" : "seinfeld", "value" : { "count" : 1, "events" : [ 5 ] } }
{ "_id" : "show", "value" : { "count" : 3, "events" : [ ] } }
{ "_id" : "today", "value" : { "count" : 1, "events" : [ 3 ] } }
{ "_id" : "tonight", "value" : { "count" : 3, "events" : [ ] } }
{ "_id" : "utah", "value" : { "count" : 1, "events" : [ 10 ] } }
{ "_id" : "world", "value" : { "count" : 1, "events" : [ 8 ] } }
[{ "_id" : 1, "dt" : "2010-07-20 09:00", "dur" : 60, "slots" : [ "2010-07-20 09:00", "2010-07-20 09:30" ], "rating" : "TV14", "qualifiers" : [ "CC", "Stereo", "HDTV" ], "tags" : [ "tonight", "show", "jay", "leno", "british", "invasion" ], "type" : "Series", "seriesId" : "183895", "title" : "The Tonight Show With Jay Leno", "genre" : "talk", "callSign" : "ESPN", "episodeTitle" : "The British Invasion" }
{ "_id" : 2, "dt" : "2010-07-20 10:00", "dur" : 30, "slots" : [ "2010-07-20 10:00" ], "qualifiers" : [ "CC" ], "tags" : [ "first", "business" ], "type" : "Series", "seriesId" : "196748", "title" : "First Business", "genre" : "bus_financial", "callSign" : "ESPN" }
{ "_id" : 3, "dt" : "2010-07-20 10:30", "dur" : 30, "slots" : [ "2010-07-20 10:30" ], "qualifiers" : [ "CC", "HDTV", "New" ], "tags" : [ "early", "today" ], "type" : "Series", "seriesId" : "185301", "title" : "Early Today", "genre" : "bus_financial", "callSign" : "ESPN" }
{ "_id" : 4, "dt" : "2010-07-20 11:00", "dur" : 30, "slots" : [ "2010-07-20 11:00" ], "qualifiers" : [ "CC", "New" ], "tags" : [ "ksl", "5", "news", "first", "edition" ], "type" : "Series", "seriesId" : "677055", "title" : "KSL 5 News First Edition", "genre" : "news", "callSign" : "ESPN" }
{ "_id" : 5, "dt" : "2010-07-20 13:00", "dur" : 60, "slots" : [ "2010-07-20 13:00", "2010-07-20 13:30" ], "rating" : "TV14", "qualifiers" : [ "CC", "Stereo", "HDTV" ], "tags" : [ "seinfeld", "comeback" ], "type" : "Series", "seriesId" : "183875", "title" : "Seinfeld", "genre" : "sitcom", "callSign" : "ESPN", "episodeTitle" : "The Comeback" }
{ "_id" : 6, "dt" : "2010-07-21 09:00", "dur" : 60, "slots" : [ "2010-07-21 09:00", "2010-07-21 09:30" ], "rating" : "TV14", "qualifiers" : [ "CC", "Stereo", "HDTV" ], "tags" : [ "tonight", "show", "jay", "leno", "british", "invasion" ], "type" : "Series", "seriesId" : "183895", "title" : "The Tonight Show With Jay Leno", "genre" : "talk", "callSign" : "ESPN", "episodeTitle" : "The British Invasion" }
{ "_id" : 7, "dt" : "2010-07-20 09:00", "dur" : 6, "slots" : [ "2010-07-20 09:00" ], "rating" : "TV14", "qualifiers" : [ "CC", "Stereo", "HDTV" ], "tags" : [ "tonight", "show", "jay", "leno", "british", "invasion" ], "type" : "Series", "seriesId" : "183895", "title" : "The Tonight Show With Jay Leno", "genre" : "talk", "callSign" : "WABC", "episodeTitle" : "The British Invasion" }
{ "_id" : 8, "dt" : "2010-07-20 09:06", "dur" : 84, "slots" : [ "2010-07-20 09:00", "2010-07-20 09:30", "2010-07-20 10:00" ], "qualifiers" : [ "CC", "New" ], "tags" : [ "abc", "world", "news" ], "type" : "Series", "seriesId" : "184051", "title" : "ABC World News Now", "genre" : "news", "callSign" : "WABC" }
{ "_id" : 9, "dt" : "2010-07-20 10:30", "dur" : 30, "slots" : [ "2010-07-20 10:30" ], "qualifiers" : [ "CC", "New" ], "tags" : [ "america", "morning" ], "type" : "Series", "seriesId" : "185950", "title" : "America This Morning", "genre" : "news", "callSign" : "WABC" }
{ "_id" : 10, "dt" : "2010-07-20 11:00", "dur" : 120, "slots" : [
"2010-07-20 11:00",
"2010-07-20 11:30",
"2010-07-20 12:00",
"2010-07-20 12:30"
], "qualifiers" : [ "CC", "New" ], "tags" : [ "good", "morning", "utah" ], "type" : "Series", "seriesId" : "706833", "title" : "Good Morning Utah", "genre" : "news", "callSign" : "WABC" }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment