<commit_before>#!ruby
# encoding: utf-8

require 'letsfreckle'
require 'date'
require 'pp'

# calculate total hours logged for the given date
def get_total_hours_logged_on(date)
	LetsFreckle.configure do
		account_host 'redacted'
		username 'redacted'
		token '<PASSWORD>'
	end
	
	date_for_freckle = date.strftime('%F')
	entries_on_that_date = LetsFreckle::Entry.find(from: date_for_freckle, to: date_for_freckle)
	entries_hours = entries_on_that_date.map do |entry|
		minutes_to_hours(entry.minutes)
	end
	total_hours = entries_hours.reduce(0, &:+)
	return total_hours
end

def minutes_to_hours(minutes)
	return minutes.to_f / 60
end

if __FILE__ == $0 # if this file is run directly
	total_hours_logged = get_total_hours_logged_on(Date.today)
	puts "hours worked today, so far:"
	pp total_hours_logged
end
<commit_msg>running freckle-hours-worked finds hours worked in range of days<commit_after>#!ruby
# encoding: utf-8

require 'letsfreckle'
require 'date'
require 'pp'

# calculate total hours logged for the given date
def get_total_hours_logged_on(date)
	LetsFreckle.configure do
		account_host 'redacted'
		username 'redacted'
		token '<PASSWORD>'
	end
	
	date_for_freckle = date.strftime('%F')
	entries_on_that_date = LetsFreckle::Entry.find(from: date_for_freckle, to: date_for_freckle)
	entries_hours = entries_on_that_date.map do |entry|
		minutes_to_hours(entry.minutes)
	end
	total_hours = entries_hours.reduce(0, &:+)
	return total_hours
end

def minutes_to_hours(minutes)
	return minutes.to_f / 60
end

if __FILE__ == $0 # if this file is run directly
	total_hours_logged = get_total_hours_logged_on(Date.today)
	puts "hours worked today, so far:"
	pp total_hours_logged
	
	puts "loading past data…"
	range_of_past_days = (0..7)
	daily_counts = range_of_past_days.map do |days_ago|
		date = Date.today.prev_day(days_ago)
		puts days_ago.to_s + "…"
		hours_logged = get_total_hours_logged_on(date)
	end
	pp daily_counts
	puts "maximum hours worked in that time period:", daily_counts.max
end

{'fraction_non_alphanumeric': 0.08868958644743398, 'fraction_numerical': 0.005979073243647235, 'mean_word_length': 5.605263157894737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4191207', 'n_tokens_mistral': 818, 'n_tokens_neox': 747, 'n_words': 181}