Sha256: 954f4addd21daac9d2798c92481f875c3b161ed7e1513467408b8779e2c89f9b
Contents?: true
Size: 960 Bytes
Versions: 1
Compression:
Stored size: 960 Bytes
Contents
module Harvest class Reports < Harvest::Base # GET /projects def projects Mash.new(self.class.get("/projects")).projects end # GET /projects/#{project_id}/entries?from=YYYYMMDD&to=YYYYMMDD def project_entries(project_id, from, to, user_id=nil) opts = {:from => from, :to => to} opts[:user_id] = user_id if user_id Mash.new(self.class.get("/projects/#{project_id}/entries", :query => opts)).day_entries end def total_project_hours(project_id, from, to, user_id=nil) pe = project_entries(project_id, from, to, user_id) total = 0.0 if pe pe.each {|msh| total += msh.hours} end total end # [['proj1', 25.5], ['proj2', 33.3]] def project_totals(from=7.days.ago, to=Date.today) @pt = [] projects.each do |p| hrs = total_project_hours(p.id, from, to) @pt << [p.name, hrs] if hrs > 0 end @pt end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
harvestr-0.0.1 | lib/harvest/reports.rb |