-
Notifications
You must be signed in to change notification settings - Fork 40
Improve get jobs and get job logic with new search parameters #1695
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
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
2b60d77
[wip] feat: migrate get jobs endpoint
paaragon 23eeec4
[wip] feat: migrate get jobs endpoint
paaragon f952fbc
[wip] first version of migrate-get_jobs-endpoint
paaragon 4f58099
[wip] first version of migrate-get_jobs-endpoint
paaragon cc04af8
first version of get-jobs endpoint
paaragon 820a0a2
add new filters (status, created_after) for get_jobs
paaragon 7b2e0a8
add get_provider_jobs endpoint
paaragon 550b19b
add filters in jobs endpoints:
paaragon 49e9733
Merge branch 'main' into feat/migrate-get-jobs-endpoint
paaragon 9f2ea0c
add test to cover get_jobs and get_provider_jobs
paaragon 86027d2
fix jobs repository style
paaragon 6aaca26
fix lint
paaragon af5fe91
refactor
paaragon 71fd9e6
add programsummaryserializer
paaragon 287d54e
Merge branch 'main' into feat/migrate-get-jobs-endpoint
paaragon 8a909c2
update jobs and provider_jobs client methods
paaragon 5a5e336
Merge branch 'main' into feat/migrate-get-jobs-client-methods
korgan00 bdfa3eb
rework input serializer
korgan00 6c35752
fix imports
korgan00 583fe48
unroll output serializer
korgan00 2aeeee9
rename use case to be consistent
korgan00 64a15df
change doc comment
korgan00 2197dbd
Merge branch 'main' into feat/migrate-get-jobs-client-methods
korgan00 064d37b
change method docs
korgan00 3a34d3c
improve tests
korgan00 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
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,43 @@ | ||
"""This module contains the usecase get_jos""" | ||
import logging | ||
from typing import List | ||
|
||
from django.contrib.auth.models import AbstractUser | ||
|
||
from api.domain.exceptions.not_found_error import NotFoundError | ||
from api.models import Job | ||
from api.repositories.functions import FunctionRepository | ||
from api.repositories.jobs import JobsRepository, JobFilters | ||
|
||
logger = logging.getLogger("gateway.use_cases.jobs") | ||
|
||
|
||
class JobsListUseCase: | ||
"""Use case for retrieving user jobs with optional filtering and pagination.""" | ||
|
||
function_repository = FunctionRepository() | ||
jobs_repository = JobsRepository() | ||
|
||
def execute(self, user: AbstractUser, filters: JobFilters) -> tuple[List[Job], int]: | ||
""" | ||
Retrieve user jobs with optional filters and pagination. | ||
|
||
Returns: | ||
tuple[list[Job], int]: (jobs, total_count) | ||
""" | ||
if filters.function: | ||
function = self.function_repository.get_function( | ||
function_title=filters.function, | ||
provider_name=filters.provider, | ||
) | ||
|
||
if not function: | ||
if filters.provider: | ||
error_message = f"Qiskit Function {filters.provider}/{filters.function} doesn't exist." # pylint: disable=line-too-long | ||
else: | ||
error_message = f"Qiskit Function {filters.function} doesn't exist." | ||
raise NotFoundError(error_message) | ||
|
||
queryset, total = self.jobs_repository.get_user_jobs(user=user, filters=filters) | ||
|
||
return list(queryset), total |
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.