Sha256: c6facdb345fe3fe6f9d27f3e64b4a05da48534c29c2832b25a9c572a30cd4db2
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'benchmark' require 'colorize' require 'active_support/core_ext/time' module GitWakaTime # Integrates the nested hash from mapper with actions api class Query def initialize(commits, project, _path = nil) @commits = commits @api_limit = 15 @project = project @actions = [] @requests = time_params end def get @requests.each do |params| Log.new "Requesting actions #{params[:start].to_date} to #{params[:end].to_date}".red @actions = @actions.concat Actions.new(params).actions end Actions.new(actions: @actions.uniq(&:id)).actions_to_durations end def time_params commits = @commits.map(&:date) d_commits = @commits.map do |c| c.files.map(&:dependent_commit).compact.map(&:date) end timestamps = (commits + d_commits.flatten).uniq num_requests = (timestamps.first.to_date - timestamps.last.to_date) / @api_limit i = 0 request_params = num_requests.to_f.ceil.times.map do params = { start: (timestamps.last.to_date + (i * @api_limit)).to_time.beginning_of_day, end: (timestamps.last.to_date + ((i + 1) * @api_limit)).to_time.end_of_day, project: @project } i += 1 params end request_params end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitwakatime-0.0.3 | lib/gitwakatime/query.rb |
gitwakatime-0.0.2 | lib/gitwakatime/query.rb |