make get_by_tags actually work
[ajatus.git] / plugins / ajatus / examples / hours_to_nabaztag.php
blob5e4964174f27813f245856ab6583b045fd964b9c
1 <?php
2 require_once(realpath(dirname(__FILE__) . '/') . '/../ajatus.php');
3 require('Services/Nabaztag.php');
5 if (count($argv) != 4)
7 die("Usage: php hours_to_nabaztag.php dbname serialno apitoken\n");
9 $nabaztag = new Services_Nabaztag($argv[2], $argv[3]);
11 try
13 $ajatus = new ajatus(array(
14 'db' => $argv[1]
15 ));
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
26 'filter' => array
28 'and' => 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
41 'filter' => array
43 'and' => 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";
53 try
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)
59 die($e);