Permalink
Browse files

Cache the project so we don't have to make a request for each line it…

…em, only the ones for a project we haven't seen yet.
  • Loading branch information...
1 parent c971847 commit 2a3b4f2a00f61f4cfe65cfd4d8f87cb2b58809b5 Brian Cooke committed Mar 1, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 fbtoday.rb
View
@@ -12,9 +12,16 @@
end
hours = 0.0
+projects = {}
FreshBooks::TimeEntry.list(:date_from => date, :date_to => date).each do |te|
- project = FreshBooks::Project.get(te.project_id)
+ project = projects[te.project_id]
+
+ if project.nil?
+ project = FreshBooks::Project.get(te.project_id)
+ projects[te.project_id] = project
+ end
+
hours += te.hours
puts "#{te.hours}\t#{project.name}\t#{te.notes}"
end

0 comments on commit 2a3b4f2

Please sign in to comment.