class Api::TimemachineController < Api::ApiController
MAX_IN_ELEMENTS=990
#
- # TODO date range
# GET /api/timemachine
#
def index
resource_id = params[:resource]
metric_keys = params[:metrics].split(',')
metrics = Metric.by_keys(metric_keys)
+ first_date = parse_datetime(params[:first_date])
+ last_date = parse_datetime(params[:last_date])
@resource=Project.by_key(resource_id)
if @resource.nil?
end
snapshots = Snapshot.find(:all,
- :conditions => {:project_id => @resource.id, :status => Snapshot::STATUS_PROCESSED},
+ :conditions => ['created_at>=? AND created_at<=? AND project_id=? AND status=?',
+ first_date, last_date, @resource.id, Snapshot::STATUS_PROCESSED],
:order => 'created_at')
# Oracle limitation : no more than 1000 elements in IN clause