-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Create end point last entries #215 #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job.
@@ -470,14 +474,56 @@ def get_all(self, conditions: dict = None, **kwargs) -> list: | |||
max_count=limit, | |||
) | |||
|
|||
def get_last_projects_worked( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want this function to be called something like : get_latest_entries
or get_latest
. I think get_last_project may be a bit misleading.
@@ -256,6 +256,18 @@ def post(self): | |||
return time_entries_dao.create(ns.payload), HTTPStatus.CREATED | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add
TODO: Once this endpoint is working as expected in prod, review and remove unnecessary filter args. As we are using same attributes_filter as the get_all endpoint and some of the args are unnecessary for this endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exactly? should not we write proper tests instead of adding this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enriquezrene We put this TODO, in order to discuss in the next meeting. about the filters that we probably going to use in this endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exactly? should not we write proper tests instead of adding this?
@enriquezrene in this part of the code, Paul copied functionality of another endpoint to make it work. It works fine as it , It only seems to me that there may be extra logic that could be avoided. For that reason, I wanted to add a reminder to review that later.
We can enforce to remove that extra logic now or later, I am ok with both options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do it now please
@@ -256,6 +256,18 @@ def post(self): | |||
return time_entries_dao.create(ns.payload), HTTPStatus.CREATED | |||
|
|||
|
|||
@ns.route('/latest') | |||
class TimeEntries(Resource): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even tough seems working fine with this, please let's rename this class to LatestTimeEntries
or Latest
or LatestEntries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am really sick of this file, it is so hard to understand what the heck is happening here. Please @PaulRC-ioet let's move all the classes to their own separate files. If we find a good reason to keep some in the same file please let me know, otherwise, please refactor this file to have many small files. I know you did not do this, but it is a good time to do some refactor tasks here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I agree with @Angeluz-07 on renaming this class. Classes like this
@ns.route('/latest')
class TimeEntries(Resource):
should remain here, but repositories, daos and all the other things please move them into their own separate files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am according to you @enriquezrene , but this refactors tasks I think we have to create another ticket to do this refactor. In order to keep for now the order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please not, if you want to create another ticket but as I mentioned in the meeting, each time we update the backend let's Refactor the code we find
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so I will do some refactor task here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please not, if you want to create another ticket but as I mentioned in the meeting, each time we update the backend let's Refactor the code we find
Good idea.
but repositories, daos and all the other things please move them into their own separate files.
Got it.
efff1aa
to
91cd576
Compare
@@ -470,14 +474,56 @@ def get_all(self, conditions: dict = None, **kwargs) -> list: | |||
max_count=limit, | |||
) | |||
|
|||
def get_last_projects_worked( | |||
self, conditions: dict = None, **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move the class TimeEntriesCosmosDBDao
to its own file. The current time_entries_model.py
file is too big, we can no keep adding more code in it. Reading the code is a nightmare, adding changes will become harder as time passes and more features are added. Method name might be get_latest_entries_by_project
for id_project in projects_ids: | ||
conditions.update({"project_id": id_project}) | ||
|
||
limit = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why limit 2, don't you need only one record?
max_count=limit, | ||
) | ||
|
||
if len(latest) >= 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be
if len(latest)>0: ...
custom_sql_conditions=custom_query, | ||
date_range=date_range, | ||
max_count=limit, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are not you missing an order by clause somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already getting the values in descendent order by default so, no order clause is needed.
@@ -256,6 +256,18 @@ def post(self): | |||
return time_entries_dao.create(ns.payload), HTTPStatus.CREATED | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exactly? should not we write proper tests instead of adding this?
@@ -256,6 +256,18 @@ def post(self): | |||
return time_entries_dao.create(ns.payload), HTTPStatus.CREATED | |||
|
|||
|
|||
@ns.route('/latest') | |||
class TimeEntries(Resource): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am really sick of this file, it is so hard to understand what the heck is happening here. Please @PaulRC-ioet let's move all the classes to their own separate files. If we find a good reason to keep some in the same file please let me know, otherwise, please refactor this file to have many small files. I know you did not do this, but it is a good time to do some refactor tasks here.
@@ -256,6 +256,18 @@ def post(self): | |||
return time_entries_dao.create(ns.payload), HTTPStatus.CREATED | |||
|
|||
|
|||
@ns.route('/latest') | |||
class TimeEntries(Resource): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I agree with @Angeluz-07 on renaming this class. Classes like this
@ns.route('/latest')
class TimeEntries(Resource):
should remain here, but repositories, daos and all the other things please move them into their own separate files.
9e4a460
to
46d3fd4
Compare
An endpoint that returns the latest time-entries created belonging to different projects