Daily events chart

×

Error message

Deprecated function: Array and string offset access syntax with curly braces is deprecated in include_once() (line 20 of /home/eventloggers/public_html/includes/file.phar.inc).

Once you become a Member you'll be able to see a visual display of all your basic information and make changes easily.

DATE_SUB(CURDATE(),INTERVAL 20 DAY) ", array(":the_uid" => $user->uid)); foreach ($my_week AS $my_event) { $startDay = date('D, M j', strtotime($my_event->start)); $startHour = date('H', strtotime($my_event->start)); $startMin = date('i', strtotime($my_event->start)); if ( substr($my_event->title, 0, 8) == 'exercise') { $my_event_colour = 'exercise'; }else{ $my_event_colour = $my_event->title ; } if (strlen($my_event->end) > 6) { $endDay = date('D, M j', strtotime($my_event->end)); $endHour = date('H', strtotime($my_event->end)); $endMin = date('i', strtotime($my_event->end)); if ($startDay <> $endDay) { $my_events[] = ' [ \'' . $startDay . '\', \'' . $my_event->title . '\', \'' . $my_event->nid . '\', \'' . $colours[$my_event_colour] . '\', new Date(0,0,0,' . $startHour . ',' . $startMin . ',0), new Date(0,0,0,23,59,59) ]'; $my_events[] = ' [ \'' . $endDay . '\', \'' . $my_event->title . '\', \'' . $my_event->nid . '\', \'' . $colours[$my_event_colour] . '\', new Date(0,0,0,0,0,0), new Date(0,0,0,' . $endHour . ',' . $endMin . ',0) ]'; }else{ $my_events[] = ' [ \'' . $startDay . '\', \'' . $my_event->title . '\', \'' . $my_event->nid . '\', \'' . $colours[$my_event_colour] . '\', new Date(0,0,0,' . $startHour . ',' . $startMin . ',0), new Date(0,0,0,' . $endHour . ',' . $endMin . ',0) ]'; } }else{ $endHour = $startHour; $endMin = $startMin; $my_events[] = ' [ \'' . $startDay . '\', \'' . $my_event->title . '\', \'' . $my_event->nid . '\', \'' . $colours[$my_event_colour] . '\', new Date(0,0,0,' . $startHour . ',' . $startMin . ',0), new Date(0,0,0,' . $endHour . ',' . $endMin . ',0) ]'; } #print "$my_event->nid $my_event->start $startDay $my_event->title $startHour : $startMin and $endHour : $endMin
"; } $my_eventString = implode(',', $my_events); ############################# # RescueTime stuff ############################# $my_key = db_query("SELECT field_profile_rescuetime_key_value FROM sen_field_data_field_profile_rescuetime_key WHERE entity_id = :uid LIMIT 1", array(":uid" => $user->uid ))->fetchField(); if (strlen($my_key) >10 ) { ### skip this whole section if the user has no RT key in their profile $my_start_day = date('Y-m-d', time()); $my_daysago = 20; $my_days = array($my_start_day); for ($x = 1; $x < $my_daysago; $x++) { $y = (-1 * $x) . ' days'; $my_days[] = date("Y-m-d", strtotime($y, strtotime($my_start_day))); } foreach ($my_days AS $my_day) { unset($chunks); $t = 0; for ($x = 0; $x < 288; $x++) { $key = date('H:i', strtotime(date('Y-m-d') . ' + ' . $t . ' minutes')); $chunks[$x] = array($key); $t = $t + 5; } $my_chart_day = date('D, M j', strtotime($my_day)); $url = 'https://www.rescuetime.com/anapi/data?rk=activity&by=interval&i=minute&format=json&rb=' . $my_day . '&re=' . $my_day . '&key=' . $my_key . ''; #print $url; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result_rescue = curl_exec($ch); curl_close($ch); $result_rescue = str_replace("Gov't", "Govt", $result_rescue); $rescue_data = json_decode($result_rescue, true); #print_r($rescue_data); $rescue_data_count = count($rescue_data["rows"]); #print '
' . $rescue_data_count . '
'; for ($x = 0; $x < $rescue_data_count; $x++) { $my_timechunk_hour = substr($rescue_data["rows"][$x][0], 11, 2); $my_timechunk_minute = substr($rescue_data["rows"][$x][0], 14, 2); $my_index = ($my_timechunk_hour * 12) + ($my_timechunk_minute / 5) ; #print '
' . $my_timechunk_hour . ' - ' . $my_timechunk_minute . ' - ' . $my_index . ''; $my_duration = $rescue_data["rows"][$x][1]; $my_activity = $rescue_data["rows"][$x][3]; $my_category = $rescue_data["rows"][$x][4]; $my_productivity = $rescue_data["rows"][$x][5]; if (!isset($chunks[$my_index]['longest']) ) { $chunks[$my_index]['longest'] = $my_activity . ' (' . $my_duration . ' secs)' ; } $chunks[$my_index]['duration'] = $chunks[$my_index]['duration'] + $my_duration; $chunks[$my_index]['productivity'] = $chunks[$my_index]['productivity'] + ( $my_duration * $my_productivity); $chunks[$my_index]['categories'][$my_category]["duration"] = $chunks[$my_index]['categories'][$my_category]["duration"] + $my_duration; $chunks[$my_index]['categories'][$my_category]["productivity"] = $my_productivity; $chunks[$my_index]['categories'][$my_category]['activities'][$my_activity] = $chunks[$my_index]['categories'][$my_category][$my_activity] + $my_duration; } #print '
';
#print_r($chunks[6]);
#print_r($chunks[7]);
#print '
--------------------------------------------------
'; $c = 0; $e = 'N'; unset($a); for ($x = 0; $x < 288; $x++) { if ($e == 'Y') { if ($chunks[$x]['duration'] > 60 ) { $a[$c]['duration'] = $a[$c]['duration'] + $chunks[$x]['duration']; $a[$c]['productivity'][] = $chunks[$x]['productivity']; $a[$c]['longest'][] = $chunks[$x]['longest']; foreach ($chunks[$x]['categories'] AS $key=>$value){ $a[$c]['categories'][$key]['duration'] = $a[$c]['categories'][$key]['duration'] + $value['duration']; $a[$c]['categories'][$key]['productivity'] = $value['productivity']; foreach ($chunks[$x]['categories'][$key]['activities'] AS $activity=>$duration){ $a[$c]['categories'][$key]['activities'][$activity] = $a[$c]['categories'][$key]['activities'][$activity] + $duration ; } } }else{ # activity has ended $z = $x - 1; $my_end_trimmed = date("H:i", strtotime($chunks[$z][0]) + $chunks[$z]['duration']); $a[$c]['end'] = $my_end_trimmed; #$a[$c]['end'] = $chunks[$x][0];# the above 3 lines trim the end time $e = 'N'; $c = $c + 1; } }else { # $e == 'N' if ($chunks[$x]['duration'] > 60 ) { $e = 'Y'; $a[$c]['duration'] = $chunks[$x]['duration']; $a[$c]['productivity'][] = $chunks[$x]['productivity']; $a[$c]['longest'][] = $chunks[$x]['longest']; #$my_start_trimmed = date("H:i", strtotime($chunks[$x][0]) + (600 - $chunks[$x]['duration']) ); #$a[$c]['start'] = $my_start_trimmed; $a[$c]['start'] = $chunks[$x][0]; # need to trim the start time foreach ($chunks[$x]['categories'] AS $key=>$value){ $a[$c]['categories'][$key]['duration'] = $a[$c]['categories'][$key]['duration'] + $value['duration']; $a[$c]['categories'][$key]['productivity'] = $value['productivity']; foreach ($chunks[$x]['categories'][$key]['activities'] AS $activity=>$duration){ $a[$c]['categories'][$key]['activities'][$activity] = $a[$c]['categories'][$key]['activities'][$activity] + $duration; } } } } } if ($e == 'Y') { $a[$c]['end'] = '23:59'; } #print '
';
#print_r($a);
#print '
'; #print 'a is ' . count($a); unset($my_events); foreach ($a AS $my_event) { $startDay = $my_chart_day; $my_nid = '1111'; $my_event_colour = '#666666'; $startHour = substr($my_event['start'], 0, 2); $startMin = substr($my_event['start'], 3, 2); $endHour = substr($my_event['end'], 0, 2); $endMin = substr($my_event['end'], 3, 2); unset($event_cats); foreach ($my_event['categories'] AS $category=>$values) { $event_cats[$category] = $values['duration']; } arsort($event_cats); $top_events = array_slice($event_cats, 0, 2); unset($ttl); $i = 0; foreach ($top_events AS $key=>$value){ $event_percentage = round(($value / $my_event['duration'] * 100), 0); #print 'percentage is ' . $event_percentage . ''; $ttl[] = $key . ' (' . $event_percentage . '%)'; if ($i == 0 ) {$top_cat = $key;} $i++; } $productivity_avg = array_sum($my_event['productivity']) / $my_event['duration'] ; $my_label = ''; if ($productivity_avg > .8) { $my_label = 'Work: '; $my_event_colour = '#EF5350';} if ($top_cat == 'Video') { $my_label = 'Watching: '; $my_event_colour = '#0288D1';} # print '
';
#  print_r($top_events);
  $my_title =  $my_label . implode(', ', $ttl);
#  print '
'; $my_events[] = ' [ \'' . $startDay . '\', \'' . $my_title . '\', \'' . $my_nid . '\', \'' . $my_event_colour . '\', new Date(0,0,0,' . $startHour . ',' . $startMin . ',0), new Date(0,0,0,' . $endHour . ',' . $endMin . ',0) ]'; #print "$my_event->nid $my_event->start $startDay $my_event->title $startHour : $startMin and $endHour : $endMin
"; $summary[] = '
' . $my_event['start'] . ' - ' . $my_event['end'] . '
'; } $my_day_events[] = implode(',', $my_events); } $my_eventStringRT = implode(',', $my_day_events); #print $my_eventStringRT; } ?>
Newest Event: 
Events will appear in real-time...

What you do matters!

Use Event Loggers to track it all.

What do you want to track right now?

My thoughts My daily events My kid's events My dreams

Event Loggers is the world's most flexible system for journaling, life-logging, and personal event tracking.

Some people use it to track health issues, others use it as a food diary or as a digital journaling platform.

Some people connect their Fitbit, Google Photos and RescueTime accounts to create an automated "lifelog".

Create a free account to try it out, then use Event Loggers' built-in tools to dive in and explore your personal data.

.........