Fixed issues not exporting when they disappear

This commit is contained in:
Šesták Vít
2016-12-13 23:37:18 +01:00
parent 2d3e1cea0a
commit 5680eec2d5
7 changed files with 58 additions and 27 deletions

View File

@@ -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