generated from coulomb/repo-seed
Added rejection support for the rest of the candidate graph
This commit is contained in:
@@ -441,6 +441,75 @@ class RegistryStore:
|
||||
(capability_id, repository_id, analysis_run_id),
|
||||
)
|
||||
|
||||
def reject_candidate_capability(
|
||||
self,
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
candidate_capability_id: int,
|
||||
) -> None:
|
||||
with self.connect() as connection:
|
||||
cursor = connection.execute(
|
||||
"""
|
||||
UPDATE candidate_capabilities
|
||||
SET status = 'rejected'
|
||||
WHERE id = ?
|
||||
AND repository_id = ?
|
||||
AND analysis_run_id = ?
|
||||
AND status = 'candidate'
|
||||
""",
|
||||
(candidate_capability_id, repository_id, analysis_run_id),
|
||||
)
|
||||
if cursor.rowcount == 0:
|
||||
raise NotFoundError(
|
||||
"candidate capability "
|
||||
f"{candidate_capability_id} was not found for repository "
|
||||
f"{repository_id} analysis run {analysis_run_id}"
|
||||
)
|
||||
connection.execute(
|
||||
"""
|
||||
UPDATE candidate_features
|
||||
SET status = 'rejected'
|
||||
WHERE capability_id = ? AND repository_id = ? AND analysis_run_id = ?
|
||||
""",
|
||||
(candidate_capability_id, repository_id, analysis_run_id),
|
||||
)
|
||||
connection.execute(
|
||||
"""
|
||||
UPDATE candidate_evidence
|
||||
SET status = 'rejected'
|
||||
WHERE capability_id = ? AND repository_id = ? AND analysis_run_id = ?
|
||||
""",
|
||||
(candidate_capability_id, repository_id, analysis_run_id),
|
||||
)
|
||||
|
||||
def reject_candidate_feature(
|
||||
self,
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
candidate_feature_id: int,
|
||||
) -> None:
|
||||
self._reject_candidate_leaf(
|
||||
table="candidate_features",
|
||||
label="candidate feature",
|
||||
repository_id=repository_id,
|
||||
analysis_run_id=analysis_run_id,
|
||||
candidate_id=candidate_feature_id,
|
||||
)
|
||||
|
||||
def reject_candidate_evidence(
|
||||
self,
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
candidate_evidence_id: int,
|
||||
) -> None:
|
||||
self._reject_candidate_leaf(
|
||||
table="candidate_evidence",
|
||||
label="candidate evidence",
|
||||
repository_id=repository_id,
|
||||
analysis_run_id=analysis_run_id,
|
||||
candidate_id=candidate_evidence_id,
|
||||
)
|
||||
|
||||
def update_candidate_ability(
|
||||
self,
|
||||
repository_id: int,
|
||||
@@ -507,6 +576,33 @@ class RegistryStore:
|
||||
f"{repository_id} analysis run {analysis_run_id}"
|
||||
)
|
||||
|
||||
def _reject_candidate_leaf(
|
||||
self,
|
||||
*,
|
||||
table: str,
|
||||
label: str,
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
candidate_id: int,
|
||||
) -> None:
|
||||
with self.connect() as connection:
|
||||
cursor = connection.execute(
|
||||
f"""
|
||||
UPDATE {table}
|
||||
SET status = 'rejected'
|
||||
WHERE id = ?
|
||||
AND repository_id = ?
|
||||
AND analysis_run_id = ?
|
||||
AND status = 'candidate'
|
||||
""",
|
||||
(candidate_id, repository_id, analysis_run_id),
|
||||
)
|
||||
if cursor.rowcount == 0:
|
||||
raise NotFoundError(
|
||||
f"{label} {candidate_id} was not found for repository "
|
||||
f"{repository_id} analysis run {analysis_run_id}"
|
||||
)
|
||||
|
||||
def create_review_decision(
|
||||
self,
|
||||
repository_id: int,
|
||||
|
||||
Reference in New Issue
Block a user