Created
May 28, 2011 00:22
-
-
Save jbrecht/996447 to your computer and use it in GitHub Desktop.
Slice map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(doc) { | |
if (doc.doc_type != "resource_data") return; | |
var date_stamp = doc.node_timestamp; | |
date_stamp = date_stamp.substring(0,10); | |
var people = new Array(); | |
var arrayContains = function(testArray, testValue) { | |
for each(var val in testArray) { | |
if(val==testValue) return true; | |
} | |
return false; | |
} | |
if(doc.identity) { | |
if(doc.identity.submitter) people.push(doc.identity.submitter); | |
if(doc.identity.curator) people.push(doc.identity.curator); | |
if(doc.identity.owner) people.push(doc.identity.owner); | |
if(doc.identity.signer) people.push(doc.identity.signer); | |
} | |
if(doc.submitter) people.push(doc.submitter); | |
var emitaAll = function(value) { | |
for(person in people) { | |
emit([date_stamp, person, value], doc); | |
} | |
emit([date_stamp, null, value], doc) | |
} | |
var usedKeys = new Array(); | |
for each(var key in doc.keys) { | |
//var used = arrayContains(usedKeys, key); | |
if(!arrayContains(usedKeys, key)) { | |
emitaAll(key); | |
usedKeys.push(key); | |
} | |
} | |
for each(var schema in doc.payload_schema) { | |
emitaAll(schema); | |
} | |
if(doc.resource_data_type) emitaAll(doc.resource_data_type); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment