Skip to content

Instantly share code, notes, and snippets.

@sivabudh
Created March 30, 2015 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivabudh/17e8dd8ee421e74b1197 to your computer and use it in GitHub Desktop.
Save sivabudh/17e8dd8ee421e74b1197 to your computer and use it in GitHub Desktop.
from_date = Date.new(2015, 02, 1)
to_date = Date.civil(2015, 02, -1)
attendance_lines_by_date = File.open(ATTENDANCE_LINES_FILE)
.readlines
.map { |line_text| AttendanceLine.new line_text, ROSTER }
.select { |line| line.date >= from_date and line.date <= to_date }
.reject { |line| line.date.weekend? }
.group_by { |line| line.date }
# Get 2 earliest employees
new_lines = attendance_lines_by_date.map do |date|
date.drop(1)[0] # remove extraneous date. BOTCH - to be improved by Pac
.reject { |line| line.time < Time.parse("6:00") } # time of day starts at 6AM
.uniq { |line| line.staff } # unique the staff to get their first arrival time
.take(2) # get the first two employees
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment