Aggregating value from multple projections

I’ve created a projection called MSP which aggregates monthly streams for all users as follows

fromCategory(‘MonthlyStream’)

.foreachStream()

.when(

{

“$init” : function(s,e) { return {count:0, type:{}}},

“$any” : function(s,e) {

s.count += 1;

var key = e.body.Reason;

var val = s.type[key];

s.type[key] = !val ? e.body.Change: val += e.body.Change;

}

})

This creates an aggregated value per monthly stream which I can access using MSP/state?partition=MonthlyStream-MemberId-2015-6

Is there a way for me to aggregate the monthly values into a yearly aggregate across all members? Ideally I’d write something along the lines of

fromCategory(‘MonthlyStream-MemberId’)

.foreachStream()

.when(

{

“$init” : function(s,e) { return {count:0, type:{}}},

“$any” : function(s,e) {

s.count += 1;

var key = e.body.Reason;

var val = s.type[key];

s.type[key] = !val ? e.body.Change: val += e.body.Change;

}

})

But I can’t get a category which groups all monthlystreams per member

Thanks

Given that MemberId changes of course

Is an internal projection the right place to do this? I would imagine
this to be trivial as an external projection to some read model.

Do you mean to consume the entire stream for the member and aggregate it when requested?

Let's imagine I had a catch up subscription and I wrote to mysql. This
would seem to be a pretty trivial query at that point.

Would a catch up subscription written using the C# ClientAPI not be a one off projection instead of a continuous one? I’d want to have a continuous projection so the running totals are up to date. Also if there are a lot of events the internal projections stores the checkpoint of how far along the stream it has reached.

Also I intended to calculate all the monthly statements up front instead of creating them when they are requested.

A catch up subscription will read forever. I would checkpoint such a
thing from outside

At the moment I’m pushing all account changes into one stream, then partitioning them by member id to a member stream then again into a monthly stream per member.

Is it better to consume these streams with an external projection using the C# ClientAPI rather than creating aggregation projections in GES?

Would I then have a catch up subscription to the member stream and have a sql row per member?

I was trying to compose the annual aggregation from the monthly aggregations, perhaps this is not the right approach when using GES.