Created
March 30, 2015 06:41
-
-
Save sivabudh/17e8dd8ee421e74b1197 to your computer and use it in GitHub Desktop.
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
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