2 require_once(realpath(dirname(__FILE__
) . '/') . '/../ajatus.php');
3 require('Services/Nabaztag.php');
7 die("Usage: php hours_to_nabaztag.php dbname serialno apitoken\n");
9 $nabaztag = new Services_Nabaztag($argv[2], $argv[3]);
13 $ajatus = new ajatus(array(
17 catch (ajatus_exception
$e)
19 die( "Error initializing Ajatus! Reason:\n{$e}\n" );
22 $jsdate = ajatus_helpers_date
::unixtime_to_jsdate(date("U"));
24 $hour_reports_today_count = $ajatus->types
->hourreport
->count(array
30 array('doc.value.date.val', 'LIKE', $jsdate)
36 $dateparts = explode('-', $jsdate);
37 $jsmonthdate = "{$dateparts[0]}-{$dateparts[1]}";
39 $hour_reports_month_count = $ajatus->types
->hourreport
->count(array
45 array('doc.value.date.val', 'LIKE', $jsmonthdate)
51 echo "Hour reports for today: {$hour_reports_today_count} and for this month: {$hour_reports_month_count}\n";
55 $stat = $nabaztag->say("In Ajatus we have " . round($hour_reports_today_count) . " hours reported today, and " . round($hour_reports_month_count) . " reported this month.");
57 catch (Services_Nabaztag_Exception
$e)