I have a rather unique problem I'm trying to solve:
Based on this sample data (actual data is very many records, and at least 4 per card per day):
serial, card, rec_date, rec_time, retrieved_on
2976 00040 2010-07-29 18:57 2010-07-31 13:37:31
2977 00040 2010-07-30 09:58 2010-07-31 13:37:31
2978 00040 2010-07-30 15:33 2010-07-31 13:37:31
2979 00040 2010-07-30 16:13 2010-07-31 13:37:31
2980 00040 2010-07-30 19:41 2010-07-31 13:37:31
The records are from a time-clock system.
What I want to do is take a certain group of entries, filtered by card
and rec_date
, then determine how long the person has been working during the day and the length of each workspan, how many breaks he/she has taken, and at the end of the week get the total number of hours worked.
From the above list, 2977
is a check in, then 2978
is a check out and so on.
I'm lost at how to do this though, so I thought someone here would have an idea.
I'm using a simple class to store this data after importing else from elsewhere:
class TimeClock(models.Model):
serial = models.CharField(max_length = 16)
card_no = models.CharField(max_length = 10)
rec_date = models.DateField()
rec_time = models.TimeField()
oper_date = models.DateTimeField(default=datetime.today)