mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-17 23:04:22 +01:00
Fixed issues not exporting when they disappear
This commit is contained in:
@@ -53,7 +53,7 @@ class JiraIssueTrackerService @Inject()(absolutizer: Absolutizer, @Named("jira-s
|
||||
)).map(response => // returns responses like {"id":"1234","key":"PROJ-6","self":"https://…/rest/api/2/issue/1234"}
|
||||
try{
|
||||
val issueInfo = Json.reads[JiraNewIssueResponse].reads(response.json).get
|
||||
ExportedVulnerability(vulnerabilityName = vulnerability.name, ticket = issueInfo.key, ticketFormatVersion = ticketFormatVersion)
|
||||
ExportedVulnerability(vulnerabilityName = vulnerability.name, ticket = issueInfo.key, ticketFormatVersion = ticketFormatVersion, done = false)
|
||||
}catch{
|
||||
case e:Throwable=>sys.error("bad data: "+response.body)
|
||||
}
|
||||
|
||||
@@ -63,8 +63,14 @@ class VulnerabilityNotificationService @Inject() (protected val dbConfigProvider
|
||||
}
|
||||
|
||||
class ExportPlatform[T, U] private[VulnerabilityNotificationService] (ept: ExportPlatformTables[T, U]) {
|
||||
def changeProjects(ticketId: Int, diff: SetDiff[String], projects: ProjectsWithReports) = db.run(
|
||||
|
||||
def loadUnfinishedTickets(): Future[Seq[(Int, ExportedVulnerability[T])]] = db.run(
|
||||
ept.tickets.filter(_.done === false).result
|
||||
)
|
||||
|
||||
def changeProjects(ticketId: Int, diff: SetDiff[String], projects: ProjectsWithReports): Future[Unit] = db.run(
|
||||
DBIO.seq(
|
||||
ept.tickets.filter(_.id === ticketId).map(_.done).update(diff.newSet.isEmpty),
|
||||
ept.projects.filter(_.exportedVulnerabilityId === ticketId).delete,
|
||||
ept.projects ++= diff.newSet.map(fullId => ExportedVulnerabilityProject(ticketId, fullId)).toSet
|
||||
).transactionally
|
||||
@@ -74,7 +80,7 @@ class VulnerabilityNotificationService @Inject() (protected val dbConfigProvider
|
||||
ept.projects.filter(_.exportedVulnerabilityId inSet ticketsIds).result
|
||||
).map{_.groupBy(_.exportedVulnerabilityId).mapValues(_.map(_.projectFullId).toSet).map(identity).withDefaultValue(Set())}
|
||||
|
||||
def ticketsForVulnerabilities(vulnerabilities: Traversable[String]) = db.run(
|
||||
def ticketsForVulnerabilities(vulnerabilities: Traversable[String]): Future[Map[String, (Int, ExportedVulnerability[T])]] = db.run(
|
||||
ept.tickets.filter(_.vulnerabilityName inSet vulnerabilities).result
|
||||
).map(_.map{ rec =>
|
||||
rec._2.vulnerabilityName -> rec
|
||||
|
||||
Reference in New Issue
Block a user