jeremyFreeAgent / Bitter

Bitter is a simple but powerful analytics library
http://bitter.free-agent.fr
MIT License
129 stars 18 forks source link

Add date period stats #11

Closed jeremyFreeAgent closed 11 years ago

jeremyFreeAgent commented 11 years ago

Add a method to have stats for a given date period.

stephpy commented 11 years ago

Hi,

DatePeriod name is a bit confusing no ?

dateperiod in php has an interval (btw many results should be fetched).

Example:

$start = new \DateTime('2012-02-25 00:00:00');
$end  = new \DateTime('2012-04-01 00:00:00');
$interval = new \DateInterval('P1D');
$datePeriod = new \DatePeriod($start, $interval, $end);

$count = $bitter
    ->bitDatePeriod('active', 'active_period_example', $datePeriod)
    ->count('active_period_example')
;

$count should return an array with results by day.

Actual feature of period should imo be renamed, sorry, i've no term at this moment :s

stephpy commented 11 years ago

Or may be having an other argument wich accept a \DateInterval and make the work :) Easier.

Just crappy to have $start, $end, $interval instead of a $datePeriod object.

jeremyFreeAgent commented 11 years ago

count method does a redis BITCOUNT on the key. Also, you can call in method to know if an id is in the key.

In Bitter, you have default keys which are by year, by month, by week, by day, by hour. So you can call count and in methods on them. Example: count on July month, on 2012 year, on yesterday.

But in 1.0 you can't do that on a custom date period like count on date period from 2010-02-25 13:00:00 to 2012-12-24 10:00:00. Now in 1.1 you can with bitDatePeriod.

Your feature is more like an detail of a given date period. Example: I want to know how many user where active each day of December, or each month of 2012, or each hour of yesterday. I think it's a good idea to implement it too. :+1:

stephpy commented 11 years ago

That's what i said ;) A DatePeriod in php does not represent ONLY from date -> to date, a DatePeriod has an interval too.

shouze commented 11 years ago