Struggling with an issue, and hoped someone on here could shed some light on it.
It might be we are using the software incorrectly.
Event Store Version: 3.1.0.0
EventStore.Client: 3.0.2
We have a Continuous Projection (called AllSales) and want to perform an adhoc query on in (get the total sum of sales performed today):
Here is the query:
fromAll()
.when({
$init: function (s, e) {
return {
total: 0, count: 0
}
},
‘Tahoe.Eposity.DomainEvents.SalesTransactionLineAddedEvent’: function (s, e) {
var today = new Date(‘2015-09-01’);
var eventDate = new Date(e.data.EntryDateTime);
if (today.getDate() == eventDate.getDate() &&
today.getMonth() == eventDate.getMonth() &&
today.getFullYear() == eventDate.getFullYear()) {
s.total += e.data.LineTotal;
s.count ++;
}
}
});
In our C# code, we have a prototype to show the issue:
while(true)
{
String queryname = Guid.NewGuid().ToString();
projectionsManager = new ProjectionsManager(new ConsoleLogger(), new IPEndPoint(address, 2113), TimeSpan.FromSeconds(10));
await projectionsManager.CreateTransientAsync(queryname, query, credentials);
var result = await projectionsManager.GetStateAsync(queryname, credentials);
Console.WriteLine(result);
Thread.Sleep(1000);
}
The first time round the loop, the result contains what looks like the expected value, however, all subsequent iterations just seem like strange values (a lot of repeating values):
{“total”:859.6099999999999,“count”:77}
{“total”:261.41,“count”:23}
{“total”:163.57999999999998,“count”:14}
{“total”:163.57999999999998,“count”:14}
{“total”:41.849999999999994,“count”:5}
{“total”:41.849999999999994,“count”:5}
{“total”:163.57999999999998,“count”:14}
{“total”:163.57999999999998,“count”:14}
{“total”:41.849999999999994,“count”:5}
{“total”:261.41,“count”:23}
Are doing something fundamentally wrong?
In addition, if we chang fromAll() to fromStream(‘AllSales’) we get no results, even though that is the correct stream name.
If we take the javascript query, and run it from the Admin GUI, we always get the expected values.
Any help in this matter would be appreciated.
Steven