|
2 | 2 | from dataclasses import dataclass, field |
3 | 3 | from typing import List, Callable |
4 | 4 | from azure.cosmos import PartitionKey |
5 | | -from azure.cosmos.exceptions import CosmosResourceNotFoundError |
6 | 5 | from flask_restplus import abort |
7 | 6 | from flask_restplus._http import HTTPStatus |
8 | 7 |
|
|
30 | 29 | str_to_datetime, |
31 | 30 | get_current_year, |
32 | 31 | get_current_month, |
33 | | - get_current_day, |
34 | 32 | get_date_range_of_month, |
35 | 33 | current_datetime_str, |
36 | 34 | ) |
@@ -92,22 +90,6 @@ def __init__(self, data): # pragma: no cover |
92 | 90 | def running(self): |
93 | 91 | return self.end_date is None |
94 | 92 |
|
95 | | - @property |
96 | | - def was_left_running(self) -> bool: |
97 | | - start_date = str_to_datetime(self.start_date) |
98 | | - return ( |
99 | | - get_current_day() > start_date.day |
100 | | - or get_current_month() > start_date.month |
101 | | - or get_current_year() > start_date.year |
102 | | - ) |
103 | | - |
104 | | - @property |
105 | | - def start_date_at_midnight(self) -> str: |
106 | | - start_date = str_to_datetime(self.start_date) |
107 | | - return datetime_str( |
108 | | - start_date.replace(hour=23, minute=59, second=59, microsecond=0) |
109 | | - ) |
110 | | - |
111 | 93 | @property |
112 | 94 | def elapsed_time(self) -> timedelta: |
113 | 95 | start_datetime = str_to_datetime(self.start_date) |
@@ -416,21 +398,6 @@ def check_time_entry_is_not_started(self, data): |
416 | 398 | "The specified time entry is already running", |
417 | 399 | ) |
418 | 400 |
|
419 | | - def stop_time_entry_if_was_left_running( |
420 | | - self, time_entry: TimeEntryCosmosDBModel |
421 | | - ): |
422 | | - |
423 | | - if time_entry.was_left_running: |
424 | | - end_date = time_entry.start_date_at_midnight |
425 | | - event_ctx = self.create_event_context( |
426 | | - "update", "Stop time-entry that was left running" |
427 | | - ) |
428 | | - |
429 | | - self.repository.partial_update( |
430 | | - time_entry.id, {'end_date': end_date}, event_ctx |
431 | | - ) |
432 | | - raise CosmosResourceNotFoundError() |
433 | | - |
434 | 401 | def build_custom_query(self, is_admin: bool, conditions: dict = None): |
435 | 402 | custom_query = [] |
436 | 403 | if "user_id" in conditions: |
@@ -569,12 +536,6 @@ def find_running(self): |
569 | 536 | time_entry = self.repository.find_running( |
570 | 537 | event_ctx.tenant_id, event_ctx.user_id |
571 | 538 | ) |
572 | | - # TODO: we need to make this work using the users time zone |
573 | | - # This is disabled as part of https://github.com/ioet/time-tracker-backend/issues/160 |
574 | | - # Remove all these comments after implementing |
575 | | - # https://github.com/ioet/time-tracker-backend/issues/159 |
576 | | - # https://github.com/ioet/time-tracker-backend/issues/162 |
577 | | - # self.stop_time_entry_if_was_left_running(time_entry) |
578 | 539 | return time_entry |
579 | 540 |
|
580 | 541 | def get_worked_time(self, args: dict): |
|
0 commit comments