def test_group_by_weekday_with_sec(self):
     '''
     Test group presence entries by weekday in seconds.
     '''
     data = utils.get_data()
     group_data = utils.group_by_weekday_with_sec(data[10])
     self.assertIsInstance(group_data, dict)
     self.assertItemsEqual(group_data.keys(), [0, 1, 2, 3, 4, 5, 6])
     self.assertIsInstance(group_data[0], dict)
     self.assertDictEqual(group_data[5], {'start': [], 'end': []})
     self.assertIsInstance(group_data[0]['start'], list)
     self.assertIsInstance(group_data[0]['end'], list)
     self.assertIn(34745, group_data[1]['start'])
     self.assertIn(64792, group_data[1]['end'])
def presence_start_end_view(user_id):
    """
    Returns mean time to come to the office and mean time he leaves.
    """
    data = get_data()
    if user_id not in data:
        log.debug('User %s not found!', user_id)
        return []

    weekdays = group_by_weekday_with_sec(data[user_id])
    result = [
        (
            calendar.day_abbr[weekday],
            mean(dates["start"]),
            mean(dates["end"])
        ) for weekday, dates in weekdays.items()]

    return result