-
Notifications
You must be signed in to change notification settings - Fork 63
Update batch API endpoint, openapi documentation and add batch test #567
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
base: develop
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 21519816080Details
💛 - Coveralls |
MarcelGeo
left a comment
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.
Nice 🎉
-
we need to double check if 404 is ok if you have empty projects list or return error: 404
-
check
def get_projects_by_uuids(uuids)method inproject_api_controller.pyif everything with permissions is ok here
harminius
left a comment
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.
Very good job!
I think two things need to be discussed (to fulfill clients' requirements):
1, Shall all (valid) uuids coming from the request be part of the response or can we skip them as suggested here?
2, Do we need to differentiate between 404 and 403 here with the expose flag? I tend to make things easier by keeping only 404 error.
|
@xkello Although your approach returns a correct response, I think we need to slightly change the approach. |
harminius
left a comment
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.
Great job, we're almost there! 👍
I have only one major comment.
I have doubts about the usefulness of require_project_by_many_uuids(). At least it should return a list of projects, and the rest (by_id dict creation) should be done in the controller. However, since this function needs to list even removed projects, it doesn't seem reusable.
The idea of the help function is that it can be used in a different use case, while this function is designed for this specific usecase.
| def require_project_by_many_uuids( | ||
| uuids: list[str], permission: ProjectPermissions, scheduled=False, expose=True | ||
| uuids: list[str], permission: ProjectPermissions | ||
| ) -> list[dict]: |
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.
would be nice if it returned list[Project]
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.
Cant be done I believe since we are returning Project objects as well as per UUID errors. The Logic would have to be split somehow
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.
Dict juggling on lines 272 to 296 can nicely be done in the controller.
Now I see it can also filter out those removed projects which is desirable.
Just a bit of code moving, no logic change to make the output of this function generic and reusable.
| projects = ( | ||
| Project.query | ||
| .filter(Project.id.in_(valid_uuids)) | ||
| .filter(Project.storage_params.isnot(None)) |
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 think also these should be included in the response with 404 error
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 is already handled at line 277-284. When uuid is not present in project lists it returns 404 automatically regardless of the reason. So in a way the information why was 404 returned is lost but I dont see a reason to store that info since we dont use it - just a side note though
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 see. I'd also filter out Project.removed_at.is_(None) then.
| # First user with access to both projects | ||
| login(client, DEFAULT_USER[0], DEFAULT_USER[1]) | ||
|
|
||
| with client: |
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.
Hmm.. this is to pass current user?
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.
Yes and no, the line under is also needed. without these 2 test failure was returning error where user was none. I believe it has something to do with active request context.
|
|
||
| # must be logged in (matches suite behavior) | ||
| login(client, DEFAULT_USER[0], DEFAULT_USER[1]) | ||
| #login(client, DEFAULT_USER[0], DEFAULT_USER[1]) TODO: why needed? |
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.
rm
| type: array | ||
| description: List of project UUIDs to fetch | ||
| items: | ||
| $ref: "#/components/parameters/ProjectId" |
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's probably due to my previous comment - sorry for that, but here is the path parameter referenced
A clean solution would be to decouple the definition from the location - to move the definition under the Schema component and put the reference in the Parameters components.
Then you can safely reference the schema here in the request body definition
components:
parameters:
ProjectIdParam:
name: id
in: path
required: true
schema:
$ref: '#/components/schemas/ProjectIdSchema'
| type: object | ||
| properties: | ||
| id: | ||
| $ref: "#/components/parameters/ProjectId" |
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.
the same previous comment - reference a ProjectId schema here, not parameter
Work on ticket: https://github.com/MerginMaps/server-private/issues/3181
-from parent: https://github.com/MerginMaps/product/issues/86