Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

View combining planned and spent efforts, and planned and completed d…

…eliverables over time and WBS
  • Loading branch information...
commit 34544eeb0bce6859136f96b6d823c9deea68b196 1 parent db9b889
@bergie bergie authored
View
34 views/ProjectOverTime/map.coffee
@@ -0,0 +1,34 @@
+(doc) ->
+ return unless doc['@type'] is 'effortallocation' or doc['@type'] is 'effort' or doc['@type'] is 'deliverable'
+ return if doc['ignore']
+
+ if doc['@type'] is 'deliverable'
+ return unless doc['milestone']
+ if doc['@type'] is 'effortallocation' or doc['@type'] is 'effort'
+ return unless doc['timeslot']
+
+ genKeyDeliverable = (doc) ->
+ # We need to map a Mxx month number to year and quarter
+ monthRegExp = new RegExp('M(\\d+)');
+ monthParts = monthRegExp.exec doc['milestone']
+ monthNumber = parseInt monthParts[1]
+ year = Math.floor monthNumber / 12
+ quarter = Math.ceil (monthNumber - year * 12) / 3
+ year++ unless year is 4
+ quarter = 4 if quarter is 0
+
+ deliverableRegExp = new RegExp "http://iks-project.eu/deliverable/(\\d+)\.(\\d+)\.(\\d*)"
+ wbs = deliverableRegExp.exec doc['_id']
+
+ key = [year, quarter, Number(wbs[1]), Number(wbs[2]), Number(wbs[3])]
+
+ genKey = (doc) ->
+ return genKeyDeliverable doc if doc['@type'] is 'deliverable'
+
+ timeRegExp = new RegExp "Y(\\d)Q(\\d)"
+ taskRegExp = new RegExp "http://iks-project.eu/task/(\\d+)\.(\\d+)"
+ timeUnits = timeRegExp.exec doc['timeslot']
+ wbs = taskRegExp.exec doc['task']
+ key = [Number(timeUnits[1]), Number(timeUnits[2]), Number(wbs[1]), Number(wbs[2])]
+
+ emit genKey(doc), doc
View
30 views/ProjectOverTime/reduce.coffee
@@ -0,0 +1,30 @@
+(keys, values, rereduce) ->
+ data =
+ planned: 0.0
+ spent: 0.0
+ left: 0.0
+ deliverables: 0
+ completed: 0
+ pending: 0
+
+ if rereduce
+ for reducedData in values
+ data.planned += reducedData.planned
+ data.spent += reducedData.spent
+ data.deliverables += reducedData.deliverables
+ data.completed += reducedData.completed
+ data.left = data.planned - data.spent
+ data.pending = data.deliverables - data.completed
+ return data
+
+ for doc in values
+ if doc['@type'] is 'effortallocation'
+ data.planned += parseFloat doc.value
+ if doc['@type'] is 'effort'
+ data.spent += parseFloat doc.value
+ if doc['@type'] is 'deliverable'
+ data.deliverables++
+ data.completed++ if doc['completed']
+ data.left = data.planned - data.spent
+ data.pending = data.deliverables - data.completed
+ return data
Please sign in to comment.
Something went wrong with that request. Please try again.