lib/garb/model.rb in garb-0.9.0 vs lib/garb/model.rb in garb-0.9.1

- old
+ new

@@ -24,11 +24,13 @@ def instance_klass @instance_klass || OpenStruct end def results(profile, options = {}) - default_params = build_default_params(profile) + start_date = options.fetch(:start_date, Time.now - MONTH) + end_date = options.fetch(:end_date, Time.now) + default_params = build_default_params(profile, start_date, end_date) param_set = [ default_params, metrics.to_params, dimensions.to_params, @@ -68,14 +70,14 @@ sort = ReportParameter.new(:sort) sort << options[:sort] if options.has_key?(:sort) sort end - def build_default_params(profile) + def build_default_params(profile, start_date, end_date) { 'ids' => Garb.to_ga(profile.id), - 'start-date' => format_time(Time.now - Model::MONTH), - 'end-date' => format_time(Time.now) + 'start-date' => format_time(start_date), + 'end-date' => format_time(end_date) } end def build_page_params(options) {'max-results' => options[:limit], 'start-index' => options[:offset]} \ No newline at end of file