Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions time_tracker_api/time_entries/time_entries_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def find_all(
conditions: dict = {},
custom_sql_conditions: List[str] = [],
date_range: dict = {},
**kwargs,
):
custom_sql_conditions.append(
self.create_sql_date_range_filter(date_range)
Expand All @@ -175,6 +176,7 @@ def find_all(
conditions=conditions,
custom_sql_conditions=custom_sql_conditions,
custom_params=custom_params,
max_count=kwargs.get("max_count", None),
)

if time_entries:
Expand All @@ -198,6 +200,8 @@ def find_all(

users = AzureConnection().users()
add_user_email_to_time_entries(time_entries, users)
elif not time_entries and len(conditions) > 1:
abort(HTTPStatus.NOT_FOUND, "Time entry not found")
return time_entries

def on_create(self, new_item_data: dict, event_context: EventContext):
Expand Down Expand Up @@ -381,11 +385,14 @@ def get_all(self, conditions: dict = None, **kwargs) -> list:
HTTPStatus.FORBIDDEN, "You don't have enough permissions."
)
date_range = self.handle_date_filter_args(args=conditions)
limit = conditions.get("limit", None)
conditions.pop("limit", None)
return self.repository.find_all(
event_ctx,
conditions=conditions,
custom_sql_conditions=custom_query,
date_range=date_range,
max_count=limit,
)

def get(self, id):
Expand Down
11 changes: 11 additions & 0 deletions time_tracker_api/time_entries/time_entries_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@
)

# custom attributes filter

attributes_filter.add_argument(
'limit',
required=False,
type=int,
store_missing=False,
help="(Filter) Amount of data to return",
location='args',
)

attributes_filter.add_argument(
'user_id',
required=False,
Expand Down Expand Up @@ -191,6 +201,7 @@ class TimeEntries(Resource):
@ns.doc('list_time_entries')
@ns.expect(attributes_filter)
@ns.marshal_list_with(time_entry)
@ns.response(HTTPStatus.NOT_FOUND, 'Time entry not found')
def get(self):
"""List all time entries"""
conditions = attributes_filter.parse_args()
Expand Down