My playing about so far, with flow-of-thought-type questions

Hi ho,

I am playing with the event store by pushing the live events from Github into the store as they happen and trying to report on stuff as they happen, I have a few questions - some of which I have answered for myself by searching through the mailing list and a few which are still open

I am going to try and create a static web page (if possible, tell me if it is not) that looks something like

So for the first one, I have a projection that looks like


fromAll().whenAny(function(s, e) {
        if(e.body && e.body.repo) {
          var date = new Date(e.body.created_at)
          var dateString = date.getUTCFullYear() + '' + date.getUTCMonth() + '' + date.getUTCDate()
          linkTo('day-' + dateString, e)
        }
     }
)

Rob,

do you have system projections running?

-yuriy

I do

And the stream per day does contain the right data, for example

oops, hit return too quickly

streams/day-20121112?format=json

Gives me a nice list of events

And a typical event linked by this has the right data, for example

{

I’m thinking that I’ve just written the projection code wrong - I’m going off whatever I’ve found in the mailing list so it’s out of date and not fully understood :slight_smile:

Check that $ce-day stream is not empty. It should be populated by the system projection.

The fromCategory(‘day’) actually reads the $ce-day stream.

day-20121112 #0 [http://127.0.0.1:2113/streams/day-20121112/0](http://127.0.0.1:2113/streams/day-20121112/0) 2012-12-12T16:22:01.134309Z EventStore Entry #0

(That was found in http://127.0.0.1:2113/streams/$ce-day )

question:

$ce_day has links to the daily streams, rather than the events themselves

Am I misunderstanding the use of the category method?

Rob,

I think I know what the problem is. When you do foreachStream over a category stream (which holds event links), it does foreachStream over the the original streams where the events are stored.

I’ll address this in new builds.

-yuriy

You think it’s not something I’m doing wrong but rather a behaviour of the ES itself that needs changing?

Can I clarify how this is supposed to work then, it is my understanding from the above discussion that

  • Using linkTo with something-X will create a stream called something-X for each X that exists

  • That stream will contain a link to the original event for every event that is passed in with linkTo

  • Because I named the stream something-X, the built in streams will create a stream called $ce-something

  • That $ce-something contains a link to each of the streams that was created above (/stream/something-x/)

When doing fromCategory and foreachStream what I am saying is

  • “In this category, for each stream linked to by that category, run the following projection”

In this case, that would mean running the projection above over the stream

/streams/day-20121112/

at least that’s the desired behaviour, but for some reason this isn’t the case and soon it will be and my projection will work?

Rob,

you are right. Disregard my previous e-mail. My fix will not help you in this case.

‘linkTo’ does not write “link to link”, but writes link to the original event.

Let me check how this can be addressed.

-yuriy

Further to the above, if I go and do


  .whenAny(function(s, e) {
      if(e.body && e.body.repo) {
        var date = new Date(e.body.created_at)
        var hour = date.getUTCHours()
        if(typeof s[hour] === 'undefined')
           s[hour] = 0
        s[hour]++
      }
  })

Er, pasted that badly, I meant


fromStream('day-20121112')
  .whenAny(function(s, e) {
      if(e.body && e.body.repo) {
        var date = new Date(e.body.created_at)
        var hour = date.getUTCHours()
        if(typeof s[hour] === 'undefined')
           s[hour] = 0
        s[hour]++
      }
  })

I think foreachMatching(f(stream metadata)) could be very powerful

It would make this kind of little trick much easier

foreachMatching(function(meta) {

return meta.name.indexOf(‘day-’) === 0

})

And could do other pretty neat things :slight_smile:

In the meantime, is there any way I can get the per-day chart-data that I’m looking for based on the above?