Sha256: b3848eaf21e3e3d37141b338abe5312dea06ab4469c56b6ebb05b12f55ecc377
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 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 @requests = time_params end def get @requests.each do |params| Log.new "Requesting actions #{params[:start].to_date} to #{params[:end].to_date}".red Durations.new(params).load_actions end Durations.new(actions: actions).actions_to_durations end def actions Action.where('time >= ? and time <= ? ', @start_at, @end_at).where(project: @project) end def time_params commits = @commits.map(&:date) d_commits = CommitedFile.select(:dependent_date).all.map { |f| f.values[:dependent_date] }.compact timestamps = (commits + d_commits.flatten).uniq.sort @start_at = timestamps.first @end_at = timestamps.last # Always have a date range great than 1 as the num request will be 0/1 otherwise num_requests = ((timestamps.last.to_date + 1) - timestamps.first.to_date) / @api_limit i = 0 request_params = num_requests.to_f.ceil.times.map do params = { start: (timestamps.first.to_date + (i * @api_limit)).to_time.beginning_of_day, end: (timestamps.first.to_date + ((i + 1) * @api_limit)).to_time.end_of_day, project: @project, show: 'file,branch,project,time,id' } i += 1 params end request_params end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitwakatime-0.1.1 | lib/gitwakatime/query.rb |
gitwakatime-0.1.0 | lib/gitwakatime/query.rb |