$("[name='switch-state']").bootstrapSwitch();

if (Meteor.isClient) {
    Template.activityDashboard.rendered = function () {
        $("#engine-switch").bootstrapSwitch();
    };
}

Template.activityDashboard.helpers({
    sessiondata: function() {
        var dates = ActivityData.find({
            type: 'session'
        }).map(function(session) {
            return moment(session.start).format('LL');
        });
        console.log("dates: ", dates);
        dates = _.uniq(dates);
        return _.map(dates, function(value, index) {
            return {
                date: value,
                id: index,
                sessions: getSessions(value)
            }
        });
    },
    circularOptions: function() {
        console.log("Graph circular Options");
        console.log(this);
        return {
            'canvasSize': 250,
            'arcWidth': 10,
            'sessionValueKey': 'progressValue',
            'tweenDuration': 300,
            //'outerDivClass': 'dailyGraphOuter'+this.id,
            'innerDivClass': 'dailyGraph' + this.id,
            'containerId': 'dailyGraph' + this.id,
            'sessionValueKey': 'dailyGraphValue' + this.id,
            'sessionTextKey': 'dailyGraphText' + this.id,
        }
    },
    fillGraph: function(data) {
        console.log("Fill graph");
        console.log(data.hash.date_id);
        Session.set('dailyGraphValue' + data.hash.date_id, 8);
        Session.set('dailyGraphText' + data.hash.date_id, 'Progress');
    },
    isValidSession: function(session) {
        if (_.notNull(session.start) && _.notNull(session.end)) {
            return true;
        } else {
            return false;
        }
    }
});

Template.activityDashboardSessionList.helpers({
    formatDate: function(date) {
        return moment(date).format('LLL');
    },
});


getSessions = function(day) {
    var sessions = ActivityData.find({type: 'session'}).map(function(session){
            if (moment(session.start).format('LL') === day ){
                console.log("session", session);
                return session;
            }
        });
    return sessions;
}

@@ -1,50 +1,4 @@
-$(%22%5Bname='switch-state'%5D%22).bootstrapSwitch();%0A
 %0Aif 
@@ -273,16 +273,38 @@
         
+%7D, %7Bsort: %7B start: -1%7D
 %7D).map(f
@@ -467,22 +467,26 @@
         
-return
+sessions =
  _.map(d
@@ -660,24 +660,136 @@
         %7D);%0A
+        console.log('Sessions to report back to html');%0A        console.log(sessions);%0A        return sessions;%0A
     %7D,%0A    c
@@ -817,32 +817,34 @@
 ion() %7B%0A        
+//
 console.log(%22Gra
@@ -866,32 +866,34 @@
 ions%22);%0A        
+//
 console.log(this
@@ -1382,32 +1382,34 @@
 data) %7B%0A        
+//
 console.log(%22Fil
@@ -1419,32 +1419,34 @@
 raph%22);%0A        
+//
 console.log(data
@@ -1874,24 +1874,93 @@
 ion(date) %7B%0A
+        console.log('formatDate called');%0A        console.log(date);%0A
         retu
@@ -2029,24 +2029,70 @@
 tion(day) %7B%0A
+    console.log(%22day%22);%0A    console.log(day);%0A
     var sess
@@ -2095,16 +2095,22 @@
 sessions
+Cursor
  = Activ
@@ -2140,20 +2140,81 @@
 ssion'%7D)
-.map
+;%0A    var sessionsArray = new Array();%0A    sessionsCursor.forEach
 (functio
@@ -2225,20 +2225,16 @@
 ssion)%7B%0A
-    
         
@@ -2235,17 +2235,16 @@
       if
- 
 (moment(
@@ -2278,17 +2278,16 @@
  === day
- 
 )%7B%0A     
@@ -2297,35 +2297,27 @@
     
-    console.log(%22session%22, 
+sessionsArray.push(
 sess
@@ -2334,55 +2334,117 @@
     
+%7D%0A
     
-    return session;%0A            %7D%0A        %7D
+%7D);%0A    console.log(sessionsArray);%0A    console.log(%22return sessions: %22);%0A    console.log(sessionsArray
 );%0A 
@@ -2461,12 +2461,17 @@
 sessions
+Array
 ;%0A%7D%0A

Fix da nasty bug in collections