-
Notifications
You must be signed in to change notification settings - Fork 32
♻️ Refactor webserver projects: drops request dependency on service layer functions
#7228
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
Merged
pcrespov
merged 11 commits into
ITISFoundation:master
from
pcrespov:is468/mai-project-domain
Feb 14, 2025
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
01b1266
ruff warning
pcrespov fbd6f82
cleanup permalink
pcrespov 7b29ae7
list_projects_full_depth from app
pcrespov 2389116
list_projects depends on app now
pcrespov 2e956b0
cleanup
pcrespov 3b70a42
note
pcrespov ffa797a
split out utils for rest
pcrespov e3da62c
permalink service
pcrespov d2a9f5c
GitHK review: annotations
pcrespov e8dc000
rename
pcrespov 8b9db79
Merge branch 'master' into is468/mai-project-domain
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
services/web/server/src/simcore_service_webserver/projects/_crud_handlers_utils.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| from aiohttp import web | ||
| from models_library.api_schemas_webserver.projects import ProjectListItem | ||
| from models_library.rest_pagination import Page | ||
| from models_library.rest_pagination_utils import paginate_data | ||
| from servicelib.mimetype_constants import MIMETYPE_APPLICATION_JSON | ||
| from servicelib.rest_constants import RESPONSE_MODEL_POLICY | ||
|
|
||
| from . import _permalink_api | ||
| from ._crud_api_read import _paralell_update | ||
| from .models import ProjectDict | ||
|
|
||
|
|
||
| async def aggregate_data_to_projects_from_request( | ||
| request: web.Request, | ||
| projects: list[ProjectDict], | ||
| ) -> list[ProjectDict]: | ||
|
|
||
| update_permalink_per_project = [ | ||
| # permalink | ||
| _permalink_api.aggregate_permalink_in_project(request, project=prj) | ||
| for prj in projects | ||
| ] | ||
|
|
||
| updated_projects: list[ProjectDict] = await _paralell_update( | ||
| *update_permalink_per_project, | ||
| ) | ||
| return updated_projects | ||
|
|
||
|
|
||
| def create_page_response(projects, request_url, total, limit, offset) -> web.Response: | ||
| page = Page[ProjectListItem].model_validate( | ||
| paginate_data( | ||
| chunk=[ | ||
| ProjectListItem.from_domain_model(prj).model_dump( | ||
| by_alias=True, exclude_unset=True | ||
| ) | ||
| for prj in projects | ||
| ], | ||
| request_url=request_url, | ||
| total=total, | ||
| limit=limit, | ||
| offset=offset, | ||
| ) | ||
| ) | ||
| return web.Response( | ||
| text=page.model_dump_json(**RESPONSE_MODEL_POLICY), | ||
| content_type=MIMETYPE_APPLICATION_JSON, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.