def get_person_day_offs_for_week(person_id, year, week): """ Get all day off entries for given person, year and week. """ start, end = date_helpers.get_week_interval(year, week) start, end = get_timezoned_interval(start, end) return get_day_offs_between(start, end, person_id=person_id)
def get_week_quota_shots(person_id, year, week, project_id=None, task_type_id=None, weighted=True): """ Return shots that are included in quota comptutation for given person and week. """ start, end = date_helpers.get_week_interval(year, week) start, end = _get_timezoned_interval(start, end) if weighted: return get_weighted_quota_shots_between( person_id, start, end, project_id=project_id, task_type_id=task_type_id, ) else: return get_raw_quota_shots_between( person_id, start, end, project_id=project_id, task_type_id=task_type_id, )
def test_date(self): date_string = date_helpers \ .get_date_string_with_timezone( "2021-02-10T12:00:00", "Europe/Paris" ) self.assertEqual(date_string, "2021-02-10T13:00:00") date_string = date_helpers \ .get_simple_string_with_timezone_from_date( datetime.datetime(2021, 2, 10, 23, 30, 0), "Europe/Paris" ) self.assertEqual(date_string, "2021-02-11") date_obj = date_helpers.get_date_from_string("2021-02-10") self.assertEqual(date_obj.strftime("%Y-%m-%d"), "2021-02-10") start, end = date_helpers.get_year_interval(2021) self.assertEqual(start.strftime("%Y-%m-%d"), "2021-01-01") self.assertEqual(end.strftime("%Y-%m-%d"), "2022-01-01") start, end = date_helpers.get_month_interval(2021, 2) self.assertEqual(start.strftime("%Y-%m-%d"), "2021-02-01") self.assertEqual(end.strftime("%Y-%m-%d"), "2021-03-01") start, end = date_helpers.get_week_interval(2021, 30) self.assertEqual(start.strftime("%Y-%m-%d"), "2021-07-26") self.assertEqual(end.strftime("%Y-%m-%d"), "2021-08-02") start, end = date_helpers.get_day_interval(2021, 2, 10) self.assertEqual(start.strftime("%Y-%m-%d"), "2021-02-10") self.assertEqual(end.strftime("%Y-%m-%d"), "2021-02-11")
def get_week_time_spents(person_id, year, week, project_id=None): """ Return aggregated time spents at task level for given person and week. """ start, end = date_helpers.get_week_interval(year, week) start, end = get_timezoned_interval(start, end) entries = get_person_time_spent_entries(person_id, TimeSpent.date >= start, TimeSpent.date < end, project_id=project_id) return build_results(entries)