Skip to content

Commit 6a3d127

Browse files
committed
refactor: remove clock-out #222
1 parent f386c1e commit 6a3d127

File tree

2 files changed

+3
-46
lines changed

2 files changed

+3
-46
lines changed

tests/time_tracker_api/time_entries/time_entries_namespace_test.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ def test_get_running_should_call_find_running(
483483
'find_running',
484484
return_value=fake_time_entry,
485485
)
486-
time_entries_dao.stop_time_entry_if_was_left_running = Mock()
487486

488487
response = client.get(
489488
"/time-entries/running", headers=valid_header, follow_redirects=True
@@ -730,16 +729,14 @@ def test_summary_is_called_with_date_range_from_worked_time_module(
730729

731730

732731
def test_paginated_fails_with_no_params(
733-
client: FlaskClient,
734-
valid_header: dict,
732+
client: FlaskClient, valid_header: dict,
735733
):
736734
response = client.get('/time-entries/paginated', headers=valid_header)
737735
assert HTTPStatus.BAD_REQUEST == response.status_code
738736

739737

740738
def test_paginated_succeeds_with_valid_params(
741-
client: FlaskClient,
742-
valid_header: dict,
739+
client: FlaskClient, valid_header: dict,
743740
):
744741
response = client.get(
745742
'/time-entries/paginated?start_date=2020-09-10T00:00:00-05:00&end_date=2020-09-10T23:59:59-05:00&timezone_offset=300&start=0&length=5',
@@ -749,8 +746,7 @@ def test_paginated_succeeds_with_valid_params(
749746

750747

751748
def test_paginated_response_contains_expected_props(
752-
client: FlaskClient,
753-
valid_header: dict,
749+
client: FlaskClient, valid_header: dict,
754750
):
755751
response = client.get(
756752
'/time-entries/paginated?start_date=2020-09-10T00:00:00-05:00&end_date=2020-09-10T23:59:59-05:00&timezone_offset=300&start=0&length=5',

time_tracker_api/time_entries/time_entries_model.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from dataclasses import dataclass, field
33
from typing import List, Callable
44
from azure.cosmos import PartitionKey
5-
from azure.cosmos.exceptions import CosmosResourceNotFoundError
65
from flask_restplus import abort
76
from flask_restplus._http import HTTPStatus
87

@@ -30,7 +29,6 @@
3029
str_to_datetime,
3130
get_current_year,
3231
get_current_month,
33-
get_current_day,
3432
get_date_range_of_month,
3533
current_datetime_str,
3634
)
@@ -92,22 +90,6 @@ def __init__(self, data): # pragma: no cover
9290
def running(self):
9391
return self.end_date is None
9492

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-
11193
@property
11294
def elapsed_time(self) -> timedelta:
11395
start_datetime = str_to_datetime(self.start_date)
@@ -416,21 +398,6 @@ def check_time_entry_is_not_started(self, data):
416398
"The specified time entry is already running",
417399
)
418400

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-
434401
def build_custom_query(self, is_admin: bool, conditions: dict = None):
435402
custom_query = []
436403
if "user_id" in conditions:
@@ -569,12 +536,6 @@ def find_running(self):
569536
time_entry = self.repository.find_running(
570537
event_ctx.tenant_id, event_ctx.user_id
571538
)
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)
578539
return time_entry
579540

580541
def get_worked_time(self, args: dict):

0 commit comments

Comments
 (0)