Open bradley-holt opened 8 years ago
A temporary work around for this could be to provide an option to export a user's expense data to a CSV. These CSV files could then be manually aggregated.
I created a view that outputs CSVs using a list function the structure is this:
{
"_id": "_design/finance",
"views": {
"MYVIEW": {
"map": "YOUR MAP CODE HERE"
}
},
"language": "javascript",
"lists": {
"csv": "function (head, req) {\n var row;\n start({\n headers: { 'Content-Type': 'text/csv' },\n });\n var first = true;\n while(row = getRow()) {\n var doc = row.value;\n if (first) {\n send(Object.keys(doc).join(',') + '\\n');\n first = false;\n }\n var line = '';\n for(var i in doc) {\n // comma separator\n if (line.length > 0) {\n line += ',';\n }\n \n // output the value, ensuring values that themselves\n // contain commas are enclosed in double quotes\n var val = doc[i];\n if (typeof val == 'string' && val.indexOf(',') > -1) {\n line += '\"' + val.replace(/\"/g,'\"\"') + '\"';\n } else {\n line += val;\n }\n }\n line += '\\n';\n send(line);\n }\n}"
}
}
You can add your view code in there too an example map function could be:
function(doc) {
if (doc.collection === 'event') {
var obj = {
title: doc.title,
userDisplayName: doc.userDisplayName
};
emit(doc.dtstart, obj);
}
which emits a sub-set of the document in date order.
If you access the view with a URL of this form:
https://YOURURL/advocated2/_design/finance/_list/csv/MYVIEW
then you get a CSV file.
Allow people in a team (see #28) to view the aggregate and individual results for their team, by year and by quarter, for the following data:
Note that we also want to allow team members to see team aggregate and individual results for other data as well, but that is not in scope for this feature request.