Created
December 28, 2019 10:28
-
-
Save andrelugomes/aac84667653d5ca1466d93b9a452a50e to your computer and use it in GitHub Desktop.
Read CSV from JIRA lead time issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
require 'date' | |
csv = CSV.read('TASKS.csv', headers: true) | |
assignee = CSV.read('JIRA.csv', headers: false).drop(1).to_h | |
authors = {} | |
p assignee | |
def real_duration(duration) | |
if duration >= 8 | |
duration = (duration / 24) * 8 | |
end | |
duration | |
end | |
csv.each do |row| | |
ass = assignee[row['Key']] | |
hour = authors[ass] || 0 | |
finished_at = DateTime.parse(row['Fim']).to_time | |
started_at = DateTime.parse(row['Início']).to_time | |
duration = (finished_at - started_at) / 3600 | |
real_duration = real_duration(duration) | |
puts "#{finished_at} - #{started_at} = #{duration}/#{real_duration}" | |
authors[ass] = hour + real_duration | |
end | |
puts authors | |
authors.each do | author, hour | | |
puts hour.to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment