Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
feat: 👌 #196
  • Loading branch information
Angeluz-07 committed Jul 21, 2020
commit 2fa0bafc1534a8d80c028468a3d2e0421e9c544e
12 changes: 3 additions & 9 deletions time_tracker_api/time_entries/time_entries_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@

from commons.data_access_layer.database import EventContext
from time_tracker_api.activities import activities_model
from time_tracker_api.customers import customers_model

from utils.extend_model import (
add_project_name_to_time_entries,
add_project_info_to_time_entries,
add_activity_name_to_time_entries,
create_in_condition,
create_custom_query_from_str,
add_user_email_to_time_entries, add_customer_name_to_projects,
add_user_email_to_time_entries,
)
from utils.time import (
datetime_str,
Expand Down Expand Up @@ -220,17 +219,12 @@ def find_all(
time_entries, "activity_id"
)

customer_dao = customers_model.create_dao()
customers = customer_dao.get_all(visible_only=False)

project_dao = projects_model.create_dao()
projects = project_dao.get_all(
custom_sql_conditions=[custom_conditions], visible_only=False
)

add_customer_name_to_projects(projects, customers)

add_project_name_to_time_entries(time_entries, projects)
add_project_info_to_time_entries(time_entries, projects)

activity_dao = activities_model.create_dao()
activities = activity_dao.get_all(
Expand Down
2 changes: 1 addition & 1 deletion time_tracker_api/time_entries/time_entries_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
title='Customer Name',
max_length=50,
description='Name of the customer the entry belongs to',
example=faker.word(['development', 'QA']),
example=faker.company(),
),
}
time_entry_response_fields.update(common_fields)
Expand Down
4 changes: 2 additions & 2 deletions utils/extend_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def add_customer_name_to_projects(projects, customers):
setattr(project, 'customer_name', customer.name)


def add_project_name_to_time_entries(time_entries, projects):
def add_project_info_to_time_entries(time_entries, projects):
"""
Add attribute project_name in time-entry model, based on project_id of the
Add project info in time-entry model, based on project_id of the
time_entry
:param (list) time_entries: time_entries retrieved from time-entry repository
:param (list) projects: projects retrieved from project repository
Expand Down