bellycard/redistat — pull request #10 by joedivita (2014-01-20 02:54:46+00:00)
Title: adding redistat model + specs

Adding the Redistat "model". Currently only supports counters, but will shortly be adding functionality for: bitmaps & mosaics (mosaics being bitmap + bitmap intersection / unions).

Now with the gem included you can define a class:

```
class Visits < Redistat::Model
type :counter
resolution :days
```
and perform the following tasks:

Increment / Decrement a counter:
```
Visits.increment(id: 1, timestamp: '2014-01-01')
Visits.decrement(id: 1, timestamp: '2014-01-01')
```
Find a value of a counter for a single day / week / month / year:
```
Visits.find(id: 1, year: 2014, month: 1, day: 5) # Day
Visits.find(id: 1, year: 2014, week: 2) # Week
Visits.find(id: 1, year: 2014, month: 1) # Month
Visits.find(id: 1, year: 2014) # Year
```
Find the aggregate total over a datespan:
```
Visits.aggregate(id: 1, start_date: '2014-01-01', end_date: '2014-01-05')
```
Get the aggregate total + data points for each point at a specified interval:
```
Visits.aggregate(id: 1, start_date: '2014-01-01', end_date: '2014-01-05', interval: :days) # or=> :weeks/:months/:years
```