def datetime(self, *metric_source_ids: str) -> datetime.datetime:  # pylint: disable=unused-argument,no-self-use
     """ Return the date and time of the last measurement. """
     issue_list = self._get_issues_older_than(
         *metric_source_ids, limit_date=datetime.datetime.now())
     return max([
         max(
             utils.parse_iso_datetime_local_naive(issue[4]),
             utils.parse_iso_datetime_local_naive(issue[3])
             if issue[3] else datetime.datetime.min) for issue in issue_list
     ])
Пример #2
0
 def _get_issues_inactive_for(self, *metric_source_ids, delta: relativedelta = relativedelta(days=14)):
     try:
         overdue_issue_list = self._get_issues_older_than(*metric_source_ids, limit_date=datetime.datetime.now())
         return [issue for issue in overdue_issue_list if issue[3]
                 is not None and utils.parse_iso_datetime_local_naive(issue[3]) <= (datetime.datetime.now() - delta)]
     except IndexError as reason:
         logging.error("Jira filter result for inactive issues inadequate. Reason: %s.", reason)
         return None
Пример #3
0
 def __get_max_activity_date(self, metric_source_ids):
     last_activity_date = ''
     for plan_id in metric_source_ids:
         for task in self._retrieve_tasks(plan_id, self._retrieve_ignored_buckets(plan_id)):
             last_activity_date = \
                 max(last_activity_date, task['createdDateTime'], self._get_max_assignment_date(task))
     return utils.parse_iso_datetime_local_naive(last_activity_date) \
         if last_activity_date else datetime.datetime.min
 def __is_task_inactive(cls,
                        dt_now,
                        task,
                        nr_inactive_days: int = 14) -> bool:
     return (not cls.__is_task_overdue(
         dt_now, task)) and (dt_now - utils.parse_iso_datetime_local_naive(
             cls.__get_last_activity_date(task)) >
                             datetime.timedelta(days=nr_inactive_days))
 def __get_max_activity_date(self, metric_source_ids):
     last_activity_date = ''
     for plan_id in metric_source_ids:
         for task in self._retrieve_tasks(
                 plan_id, self._retrieve_ignored_buckets(plan_id)):
             last_activity_date = \
                 max(last_activity_date, task['createdDateTime'], self._get_max_assignment_date(task))
     return utils.parse_iso_datetime_local_naive(last_activity_date) \
         if last_activity_date else datetime.datetime.min
Пример #6
0
 def _get_urls_of_tasks(self, *metric_source_ids: str,
                        get_tasks: callable, referent_date: callable) -> List[Tuple[str, str, str]]:
     """ Return the urls for the inactive actions. """
     urls = list()
     tasks = get_tasks(*metric_source_ids)
     if tasks:
         dt_now = datetime.datetime.now()
         for task in tasks:
             time_delta = utils.format_timedelta(
                 dt_now - utils.parse_iso_datetime_local_naive(referent_date(task)))
             urls.append((self.__task_display_url.format(task_id=task['id']), task['title'], time_delta))
     return urls
 def _get_urls_of_tasks(
         self, *metric_source_ids: str, get_tasks: callable,
         referent_date: callable) -> List[Tuple[str, str, str]]:
     """ Return the urls for the inactive actions. """
     urls = list()
     tasks = get_tasks(*metric_source_ids)
     if tasks:
         dt_now = datetime.datetime.now()
         for task in tasks:
             time_delta = utils.format_timedelta(
                 dt_now -
                 utils.parse_iso_datetime_local_naive(referent_date(task)))
             urls.append(
                 (self.__task_display_url.format(task_id=task['id']),
                  task['title'], time_delta))
     return urls
 def _get_issues_inactive_for(
     self,
     *metric_source_ids,
     delta: relativedelta = relativedelta(days=14)):
     try:
         overdue_issue_list = self._get_issues_older_than(
             *metric_source_ids, limit_date=datetime.datetime.now())
         return [
             issue for issue in overdue_issue_list if issue[3] is not None
             and utils.parse_iso_datetime_local_naive(issue[3]) <=
             (datetime.datetime.now() - delta)
         ]
     except IndexError as reason:
         logging.error(
             "Jira filter result for inactive issues inadequate. Reason: %s.",
             reason)
         return None
Пример #9
0
 def _is_str_date_before(cls, str_date: str, limit_date: datetime.datetime) -> bool:
     return utils.parse_iso_datetime_local_naive(str_date) < limit_date
Пример #10
0
 def datetime(self, *metric_source_ids: str) -> datetime.datetime:  # pylint: disable=unused-argument,no-self-use
     """ Return the date and time of the last measurement. """
     issue_list = self._get_issues_older_than(*metric_source_ids, limit_date=datetime.datetime.now())
     return max([max(utils.parse_iso_datetime_local_naive(issue[4]),
                     utils.parse_iso_datetime_local_naive(issue[3]) if issue[3] else datetime.datetime.min)
                 for issue in issue_list])
Пример #11
0
 def _is_str_date_before(cls, str_date: str,
                         limit_date: datetime.datetime) -> bool:
     return utils.parse_iso_datetime_local_naive(str_date) < limit_date
 def __is_task_overdue(cls, dt_now, task) -> bool:
     return 'dueDateTime' in task \
            and task['dueDateTime'] \
            and utils.parse_iso_datetime_local_naive(task['dueDateTime']) < dt_now
Пример #13
0
 def test_parse_iso_datetime_to_local_naive(self):
     """ Test that parsing a datetime to local naive datetime works correctly. """
     self.assertEqual(
         datetime.datetime(2009, 6, 15, 3 + 7, 45, 30, tzinfo=tzutc()).astimezone(tz=tzlocal()).replace(tzinfo=None),
         utils.parse_iso_datetime_local_naive('2009-06-15T03:45:30.0000000-0700'))
Пример #14
0
 def __is_task_overdue(cls, dt_now, task) -> bool:
     return 'dueDateTime' in task \
            and task['dueDateTime'] \
            and utils.parse_iso_datetime_local_naive(task['dueDateTime']) < dt_now
Пример #15
0
 def __is_task_inactive(cls, dt_now, task, nr_inactive_days: int = 14) -> bool:
     return (not cls.__is_task_overdue(dt_now, task)) and (dt_now - utils.parse_iso_datetime_local_naive(
         cls.__get_last_activity_date(task)) > datetime.timedelta(
         days=nr_inactive_days))