ioet / ioet/time-tracker-backend
Remove duplicated code
- Dominant language
- Python
- Stars
- 5
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
In order to retrieve the time-entries to summarise the data, we were calling the method `find_all` from time_entries repository. A new method has been to do this because the existing one is retrieving additional data that is not needed. With this change we have duplicated code that needs to be refactored in the following way:
- The method
```
def find_all(
self,
event_context: EventContext,
conditions: dict = {},
custom_sql_conditions: List[str] = [],
date_range: dict = {},
):
```
should call the functionality the method
```
def find_all_entries(
self,
event_context: EventContext,
conditions: dict = {},
custom_sql_conditions: List[str] = [],
date_range: dict = {},
):
```
and then aggregate the other information needed. The implementation should look like this:
```
def find_all(
self,
event_context: EventContext,
conditions: dict = {},
custom_sql_conditions: List[str] = [],
date_range: dict = {},
):
time_entries = find_all_entries...
if time_entries:
custom_conditions = create_in_condition(time_entries, "project_id")
custom_conditions_activity = create_in_condition(
time_entries, "activity_id"
)
project_dao = projects_model.create_dao()
projects = project_dao.get_all(
custom_sql_conditions=[custom_conditions], visible_only=False
)
add_project_name_to_time_entries(time_entries, projects)
activity_dao = activities_model.create_dao()
activities = activity_dao.get_all(
custom_sql_conditions=[custom_conditions_activity],
visible_only=False,
)
add_activity_name_to_time_entries(time_entries, activities)
users = AzureConnection().users()
add_user_email_to_time_entries(time_entries, users)
return time_entries
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.