-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handler for OpenScanHub task finish
- Loading branch information
1 parent
1502962
commit dc073f1
Showing
12 changed files
with
696 additions
and
223 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,23 +1,50 @@ | ||
# Copyright Contributors to the Packit project. | ||
# SPDX-License-Identifier: MIT | ||
|
||
from typing import Optional | ||
from logging import getLogger | ||
from packit_service.worker.events import Event | ||
|
||
from ogr.abstract import GitProject | ||
from packit_service.config import ServiceConfig | ||
from packit_service.worker.events.event import AbstractResultEvent | ||
from packit_service.models import ( | ||
AbstractProjectObjectDbType, | ||
ProjectEventModel, | ||
ScanModel, | ||
) | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class OpenScanHubTaskFinishEvent(Event): | ||
class OpenScanHubTaskFinishEvent(AbstractResultEvent): | ||
def __init__( | ||
self, | ||
task_id: int, | ||
issues_added_url: str, | ||
issues_fixed_url: str, | ||
scan_results_url: str, | ||
**kwargs, | ||
): | ||
super().__init__() | ||
super().__init__(**kwargs) | ||
|
||
self.task_id = task_id | ||
self.issues_added_url = issues_added_url | ||
self.issues_fixed_url = issues_fixed_url | ||
self.scan_results_url = scan_results_url | ||
|
||
self.scan = ScanModel.get_by_task_id(task_id) | ||
self.build = self.scan.copr_build_target | ||
|
||
def get_db_project_object(self) -> Optional[AbstractProjectObjectDbType]: | ||
return self.build.get_project_event_object() | ||
|
||
def get_db_project_event(self) -> Optional[ProjectEventModel]: | ||
return self.build.get_project_event_model() | ||
|
||
def get_project(self) -> GitProject: | ||
return ServiceConfig.get_service_config().get_project( | ||
self.db_project_object.project.project_url | ||
) | ||
|
||
def get_non_serializable_attributes(self): | ||
return super().get_non_serializable_attributes() + ["build", "scan"] |
This file contains 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 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
Oops, something went wrong.