Fixed wrong map reduce
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/GenerateMapReduceCouchbase@154381 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6cdd4a4f70
commit
89433f2881
|
@ -0,0 +1,21 @@
|
||||||
|
function(doc,meta) {
|
||||||
|
if(doc.usageRecordType == "StorageUsageRecord" || doc.recordType == "StorageUsageRecord"){
|
||||||
|
if((doc.operationCount && isNaN(Number(doc.operationCount))) || (doc.duration && isNaN(Number(doc.duration)))){
|
||||||
|
emit([0, "Invalid Value", doc.id], doc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = {};
|
||||||
|
data[doc.resourceOwner] = doc.dataVolume;
|
||||||
|
var propertiesKey = [];
|
||||||
|
var timestamp=Number(doc.creationTime);
|
||||||
|
var date = new Date(timestamp);
|
||||||
|
var dataKey = [];
|
||||||
|
dataKey.push(date.getUTCFullYear());
|
||||||
|
dataKey.push(date.getUTCMonth()+1);
|
||||||
|
dataKey.push(date.getUTCDate());
|
||||||
|
dataKey.push(date.getUTCHours());
|
||||||
|
var finalKey = propertiesKey.concat(dataKey);
|
||||||
|
finalKey.unshift(doc.scope);
|
||||||
|
emit(finalKey, data);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
function(doc,meta) {
|
||||||
|
if(doc.usageRecordType == "StorageUsageRecord" || doc.recordType == "StorageUsageRecord"){
|
||||||
|
if((doc.operationCount && isNaN(Number(doc.operationCount))) || (doc.duration && isNaN(Number(doc.duration)))){
|
||||||
|
emit([0, "Invalid Value", doc.id], doc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = {};
|
||||||
|
data[doc.resourceOwner] = doc.dataVolume;
|
||||||
|
var propertiesKey = [];
|
||||||
|
var timestamp=Number(doc.creationTime);
|
||||||
|
var date = new Date(timestamp);
|
||||||
|
var dataKey = [];
|
||||||
|
dataKey.push(date.getUTCFullYear());
|
||||||
|
dataKey.push(date.getUTCMonth()+1);
|
||||||
|
dataKey.push(date.getUTCDate());
|
||||||
|
dataKey.push(date.getUTCHours());
|
||||||
|
var finalKey = propertiesKey.concat(dataKey);
|
||||||
|
finalKey.unshift(doc.scope);
|
||||||
|
emit(finalKey, data);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue