I have created a simple time tracking application in which people can TimeIn, TimeOut and mark breaks. The central object to this Tracking is an Event generated by User. This combined with UserStatus makes sure the state management is correct. Here are the schemas minus updatedAt createdAt fields:
{
userId: { type : mongoose.Schema.Types.ObjectId, required: true },
localTime: {type: Date},
userEmail: { type: String, required: true },
type: { type : String, required: true },
ip: { type : String, required: false }
}
Now I am trying to create an aggregation of a days event. The fields in my mind are totalWorkTime, totalBreakTime (in seconds), noOfBreaks but the case I am trying to tackle is when users forget to timeout. Please consider:
- Users are in far US as well as in Manilla.
- Users dont have any time period assigned to them.
- So Perhaps they can work from 11PM to 3AM by their local time.
- How the differentiate the above situation from missing timeout and it fits well with local timezones.
- Is storing local time smart? Opposed to storing UTCs.
Primary thinking was to timein and timeout at 11:59PM and 12:00AM the next day. But it dosent fit well. Any help with Schema or perhaps suggested schema shall be helpful. Thanks!
Store the times in UTC and their timezone offset.